[BUG] regex engine

Forum to discuss everything related to the current development build of Automagic.

Moderator: Martin

Locked
bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

[BUG] regex engine

Post by bogdyro » 24 Sep 2015 08:05

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

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: [BUG] regex engine

Post by bogdyro » 24 Sep 2015 09:42

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

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: [BUG] regex engine

Post by Martin » 24 Sep 2015 19:38

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

Locked