0

I am using CSV file for providing data to my tests written in webdriverIO. While reading regex commas are not read by csv file, so i am adding '&' in csv file for regex e.g : ^[0-9]{8&15}$ and then replacing '&' with ',' (comma) to make regex some like this ^[0-9]{8,15}$ but the problem is while reading this in script the {8,15} which is min and max number are not getting formed as needed. Its generating regexps something like 2{8,15}, 5{8,15} .. and so on.

I am replacing '&' with ',' using method below:

randomExpression(exp) {
       return new RandExp(exp).gen();
}
modifyRegEx(regex){
       const rgx = this.randomExpression(regex)
       return rgx.replace(/&/g, ',');
}

I tried finding ways but could not find anything, is this issue with curly braces? How to make this string recognized as regex?

arespro
  • 1
  • 1
  • 1
    Perhaps you can try escaping values with commas in CSV in the first place. Hava a look at [this](https://stackoverflow.com/a/769675/4543207) answer. – Redu Nov 24 '21 at 21:46

0 Answers0