[ubuntu-florida] GWT, Java, Javascript and REGEX

j.e.aneiros jesus.aneiros at gmail.com
Thu Sep 23 18:45:30 BST 2010


Hello everyone,

This is marginally related to Ubuntu/Linux but I think it's interesting to
see how ubiquitous REGEX is nowadays.

I was coding this morning for GWT [1] and became curious to see how my REGEX
in Java will be converted to JavaScript by the GWT compiler, so I looked for
and found that the following Java code:

if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
Window.alert("'" + symbol + "' is not a valid symbol.");
newSymbolTextBox.selectAll();
return;
}

Was converted to something like this (only the REGEX part):

(new RegExp($intern_74)).exec(symbol)

With the $intern_74 variable declared as:

$intern_74 = '^[0-9A-Z\\.]{1,10}$'

Interesting.

Have a good day.

[1] http://en.wikipedia.org/wiki/Google_Web_Toolkit

-- 
J. E. Aneiros
GNU/Linux User #190716 en http://counter.li.org
perl -e '$_=pack(c5,0105,0107,0123,0132,(1<<3)+2);y[A-Z][N-ZA-M];print;'
PK fingerprint: 5179 917E 5B34 F073 E11A  AFB3 4CB3 5301 4A80 F674
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/ubuntu-us-fl/attachments/20100923/350e67e5/attachment.htm 


More information about the Ubuntu-us-fl mailing list