Tuesday, January 27, 2015

Re: Regex matches error in production


   Jens,
 
  Thanks for addressing issue and url.

  This is working fine.
     ^\\d{0,15}(\\.\\d{1,2})?$

 Thanks,
 Bhumika


On Tuesday, 27 January 2015 15:17:38 UTC+5:30, Jens wrote:
Seems like you can not do \d{0,15}+ in JavaScript. You have to wrap it in a group (\d{0,15})+ or remove the plus quantifier.

.matches("^\\d{0,15}(\\.\\d{1,2})?$")
.matches("^(\\d{0,15})+(\\.\\d{1,2})?$")

You can easily test this using https://www.regex101.com/#javascript (you need to change the double backslash back to single backslash). On that site you can also see that \d{0,15}+ is allowed for PCRE but not for JavaScript.

Generally GWT tries to convert Java Regex to JavaScript Regex. Not sure to what extend it does so, so maybe your issue can be considered a bug.

With SuperDevMode you detect these kind of errors sooner since you always work with compiled JavaScript.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment