How to split a string using 2 different separators
I am trying to break up a date text string into the year, month, and day, but I just discovered that the date text string can separate the values using either "-" or "/" depending on the source. The script I am using (adopted from a script I got in an earlier thread) will work for one, either/or the other.
Is there a way to write a .split statement with an or condition? Below is my code.
Imagine that COVERAGE_BEG_DT can be either 01/01/2018 or 01-01-2018
const Coverage_Beg_DT = Qualtrics.SurveyEngine.getEmbeddedData('COVERAGE_BEG_DT');
Coverage_Beg_DTArr = Coverage_Beg_DT.split("/")
Qualtrics.SurveyEngine.setEmbeddedData("YOTenure",Coverage_Beg_DTArr[2])
Qualtrics.SurveyEngine.setEmbeddedData("MOTenure",Coverage_Beg_DTArr[0])
Qualtrics.SurveyEngine.setEmbeddedData("DOTenure",Coverage_Beg_DTArr[1])
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.