PDA

View Full Version : Invalid regular expression - I dont get it



werum2011
5 Oct 2012, 2:08 AM
Hello,

I have a problem using regular expressions for validating text fields in gxt (2.2.5).

Using this code:


this.dialog.getMyTextField().setRegex( "[0-9]{1,3}\\°( )?+[0-9]{1,2}(\\,[0-9]{1,6})?\\'" );
this.dialog.getMyTextField().getMessages().setRegexText( "<GG° MM,mmmmmm'>" );
this.dialog.getMyTextField().setAutoValidate( true );


I get following exception:
SyntaxError: Invalid regular expression: /[0-9]{1,3}\°( )?+[0-9]{1,2}(\,[0-9]{1,6})?\'/: Nothing to repeat

But in plain Java-Regex it works fine.
Any ideas, whats wrong with my expression? What do I have to change to make it work in GXT/JavaScript?

Thanks in advance,

micgala
10 Oct 2012, 6:34 AM
Yes. You will need a valid javascript regex.

sven
10 Oct 2012, 11:47 AM
http://www.sencha.com/forum/showthread.php?245075-Invalid-regular-expression-I-dont-get-it