up vote 0 down vote favorite
Share on Facebook

Hi,

I have a javascript that runs uses a replace with regular expressions to modify content on a page. I'm having a problem with a specific RegExp (regular expressions) quantifier, though. Every documentation I've read (and I know it work in Regex in other languages, too) says that Javascript supports the "{N}", "{N,}" and "{N,N}" quantifiers. That is, you can specify a particular number of matches you want, or a range of matches. E.g. "(zz){5,}" matches at least 10 "z" in a row, and "z{5,10}" would match any amount of "z" from 5 to 10, no more and no less.

The problem is, I can match an exact number (e.g. "z{5}") but not a range. The nearest I can figure is that it has something to do with the comma in the regex string, but I don't understand why and can't get around this. I have tried escaping the comma and even using the unicode hexidecimal string for comma (\u002C), but to no avail.

If anyone has any insight, it would be much-appreciated.

link|flag
2  
This should be on stackoverflow. – webbiedave Oct 21 at 21:19
As programmers is still in Beta you'll have to repost the question on Stack Overflow as we can't migrate it yet. – ChrisF Oct 21 at 22:34

closed as off topic by webbiedave, grokus, Bill, Walter, Thomas Owens Oct 21 at 22:00

Questions on Programmers are expected to be about subjective issues in software development, within the scope defined in the faq.

Browse other questions tagged or ask your own question.