Choosing the Right Regex Template

Can someone help me with this regex? I use Javascript and classic ASP.

checkxls = checkxls.match(/'.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?';/ig)

I need to exactly match this pattern.

I am looking for a more elegant way to do this.

+5
source share
3 answers

You can use a negative character class to avoid unnecessary backtracking:

/'[^']*'(?:, '[^']*'){13};/g

You can also remove case insensitive flags because there are no letters in your regular expression. This may give a slight performance improvement.

+6
source
/('', ){13}'';/ig
+3
source
/(?:'[^']*', ){13}'[^']*';/g
0

All Articles