Page 1 of 1

[BUG] regex engine

Posted: 24 Sep 2015 08:05
by bogdyro
First let me say that the new regex tester was a must and that it's well implemented. Maybe it would need some copy/paste functions for the code. Also I can see in the some new syntax like groups[0]. Hope it eill make its way into the scripting language :)
Anyway, I'm trying to validate some input like a number followed by the letter 'h' or 'm' like this
^(\d{1,3})(h|m) on text '80h'
It works in the regex tester. However, when used in a script I get this weird error
aused by: java.util.regex.PatternSyntaxException: Error in {min,max} interval near index 5:
(^\d{error})(h|m)
^
It seems to be a problem with the {interval}
Thx

Re: [BUG] regex engine

Posted: 24 Sep 2015 09:42
by bogdyro
Solved it by putting single quotes around the expression like this
matches(value, '\\d{2,3}(h|m)',groups)
Although the help section includes examples that use both single and double quotes. what's the differences between them I wonder

Re: [BUG] regex engine

Posted: 24 Sep 2015 19:38
by Martin
Hi,

Automagic replaces scripts within curly braces in string literals when double quotes are used (see section String Inline Expressions in the help page of action Script).
Using single quotes avoids this and is usually the right thing to use for regular expressions.

Regards,
Martin