I have some code using Oracle regex that I want to port to GWT.

public static void main( String[] args )
{
    String expression = "(abc)|(def)";
    String source = "abcdef";
    
    Pattern pattern = Pattern.compile(expression);
    Matcher matcher = pattern.matcher(source);
    
    while (matcher.find())
    {
        if (matcher.start(1) != -1)
        {
            // it's an "abc" match
        }
        else if (matcher.start(2) != -1)
        {
            // it's a "def" match
        }
        else
        {
            // error
            continue;
        }
        
        int start = matcher.start();
        int end = matcher.end();
        
        String substring = source.substring(start, end);
        System.out.println(substring);
    }
}

I’ve tried porting it to the GWT regexp library, but it uses capturing 
groups through the start(int) method, which doesn’t seem to be supported in 
GWT regexp.

Is there a way to simulate this behaviour?

Oracle regex:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/package-summary.html

GWT regexp:
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/regexp/shared/package-summary.html

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/OMSfQW17EvcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to