Re: String.matches() does not work with \p{ASCII}
hi please can u give me full code to figure out this kind of problem same thing happen to me. On Friday, August 13, 2010 10:38:37 PM UTC+1, Vlad wrote: Thanks, with the hexidecimal range 00, 7F it works. On 13 авг, 01:17, cokol eplisc...@googlemail.com wrote: as you probably know, regex is belongs to that cases not fully compatible between java and javascript, and in dev mode your GWT engine uses real JDK therefore it works, whereas after compilation your matches() is performed on the browser with its regex engne and it fails. well u have to rewrite the pattern \\p{ASCII}* to JS compatible fashion On 12 Aug., 00:39, Vlad vsinit...@gmail.com wrote: Hi, I have a simple code that works correctly in development mode but fails to run on production. Basically, I need to check if the text entered by user contains only ASCII characters. So, I do the following: String s = getTextArea().getText(); if(s.matches(\\p{ASCII}*)) { ...} else { // Some non ASCII characters found } On the production it always comes to the else section. I've tried it with IE, FireFox and Chrome. The results are the same. Any suggestions of how to fix this? -- 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+unsubscr...@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.
Re: String.matches() does not work with \p{ASCII}
hard to say, its up to the engine implementing regex, if you want to check for ascii code of each character you gonnamake a loop like function isAscii(str){ for(i=0;istr.length;i++){ if(str[i]127)return false; } return true; } when making regex its like a touring machine which scans the character applied to the pattern, so it also depends on a pattern how many chars are scanned, and in your case you want to know if a character is in ascii range, so anyway it has to scan each. there is one chance regex is faster inthis case, if its implemented natively and not interpreted. the loop above has the advantage is has not to scan all of the chars, in case its not ascii but returns after first non-ascii On 12 Aug., 19:21, Thomas Broyer t.bro...@gmail.com wrote: On 12 août, 15:40, cokol eplisc...@googlemail.com wrote: and if you really want to check for ascii why dont u just check for the ascii code? Such as [\\u-\\u007F]* try java.lang.Character to check or write in JSNI small for-each testing if decimal value of char is greater than 127 is faster than a regex evaluation Are you sure? given that trimming blanks is faster with regexes (str.replace(/^\s+/, ).replace(/\s+$/, )), I tend to think that regexes are really fast. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: String.matches() does not work with \p{ASCII}
Thanks, with the hexidecimal range 00, 7F it works. On 13 авг, 01:17, cokol eplisc...@googlemail.com wrote: as you probably know, regex is belongs to that cases not fully compatible between java and javascript, and in dev mode your GWT engine uses real JDK therefore it works, whereas after compilation your matches() is performed on the browser with its regex engne and it fails. well u have to rewrite the pattern \\p{ASCII}* to JS compatible fashion On 12 Aug., 00:39, Vlad vsinit...@gmail.com wrote: Hi, I have a simple code that works correctly in development mode but fails to run on production. Basically, I need to check if the text entered by user contains only ASCII characters. So, I do the following: String s = getTextArea().getText(); if(s.matches(\\p{ASCII}*)) { ...} else { // Some non ASCII characters found } On the production it always comes to the else section. I've tried it with IE, FireFox and Chrome. The results are the same. Any suggestions of how to fix this? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
String.matches() does not work with \p{ASCII}
Hi, I have a simple code that works correctly in development mode but fails to run on production. Basically, I need to check if the text entered by user contains only ASCII characters. So, I do the following: String s = getTextArea().getText(); if(s.matches(\\p{ASCII}*)) { ... } else { // Some non ASCII characters found } On the production it always comes to the else section. I've tried it with IE, FireFox and Chrome. The results are the same. Any suggestions of how to fix this? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: String.matches() does not work with \p{ASCII}
as you probably know, regex is belongs to that cases not fully compatible between java and javascript, and in dev mode your GWT engine uses real JDK therefore it works, whereas after compilation your matches() is performed on the browser with its regex engne and it fails. well u have to rewrite the pattern \\p{ASCII}* to JS compatible fashion On 12 Aug., 00:39, Vlad vsinit...@gmail.com wrote: Hi, I have a simple code that works correctly in development mode but fails to run on production. Basically, I need to check if the text entered by user contains only ASCII characters. So, I do the following: String s = getTextArea().getText(); if(s.matches(\\p{ASCII}*)) { ...} else { // Some non ASCII characters found } On the production it always comes to the else section. I've tried it with IE, FireFox and Chrome. The results are the same. Any suggestions of how to fix this? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: String.matches() does not work with \p{ASCII}
and if you really want to check for ascii why dont u just check for the ascii code? try java.lang.Character to check or write in JSNI small for-each testing if decimal value of char is greater than 127 is faster than a regex evaluation On 12 Aug., 15:17, cokol eplisc...@googlemail.com wrote: as you probably know, regex is belongs to that cases not fully compatible between java and javascript, and in dev mode your GWT engine uses real JDK therefore it works, whereas after compilation your matches() is performed on the browser with its regex engne and it fails. well u have to rewrite the pattern \\p{ASCII}* to JS compatible fashion On 12 Aug., 00:39, Vlad vsinit...@gmail.com wrote: Hi, I have a simple code that works correctly in development mode but fails to run on production. Basically, I need to check if the text entered by user contains only ASCII characters. So, I do the following: String s = getTextArea().getText(); if(s.matches(\\p{ASCII}*)) { ...} else { // Some non ASCII characters found } On the production it always comes to the else section. I've tried it with IE, FireFox and Chrome. The results are the same. Any suggestions of how to fix this? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: String.matches() does not work with \p{ASCII}
On 12 août, 15:40, cokol eplisc...@googlemail.com wrote: and if you really want to check for ascii why dont u just check for the ascii code? Such as [\\u-\\u007F]* try java.lang.Character to check or write in JSNI small for-each testing if decimal value of char is greater than 127 is faster than a regex evaluation Are you sure? given that trimming blanks is faster with regexes (str.replace(/^\s+/, ).replace(/\s+$/, )), I tend to think that regexes are really fast. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.