Thursday, November 11, 2010

Re: how to get regex(Pattern and Matcher) working in client side

Thats nice that they finally added full regex capability. If you need
to access a capture group in older versions of GWT use this:

public static native String getRegexGroup(String toSearch, String
regex, int groupNum)
/*-{
return toSearch.match(regex)[groupNum];
}-*/;

Or if you need to access multiple groups use this:

public static native JsArrayString getRegexResult(String toSearch,
String regex)
/*-{
return toSearch.match(regex);
}-*/;

On Nov 11, 4:18 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 11 nov, 20:34, Jim Douglas <jdou...@basis.com> wrote:
>
> > This can be used in GWT client code:
>
> >http://download.oracle.com/javase/6/docs/api/java/lang/String.html#ma...)
>
> > (Of course, you still need to be aware of the differences between Java
> > and JavaScript regex implementations).
>
> > To see if a given Java feature will work in GWT client code, see:
>
> >http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html
>
> See alsohttp://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g...
> which mimics the JS RegExp API and can also be used on the server-side
> (or unit tests without GWTTestCase).

--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate