Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex elegant pattern match

Tags:

regex

Can someone maybe help me with this regex? I am using Javascript and classic ASP.

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

I need to match this pattern exactly.

I am looking for a more elegant way of doing this.

like image 609
Gerald Ferreira Avatar asked Aug 08 '10 22:08

Gerald Ferreira


1 Answers

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

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

You can also drop the case-insensitive flags since there are no letters in your regular expression. This might give a small performance improvement.

like image 114
Mark Byers Avatar answered Oct 01 '22 03:10

Mark Byers