blob: 5eae1c1d57d53119fb71685dc31c63f30877a304 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package gwtquery.client;
import com.google.gwt.core.client.JavaScriptObject;
/**
*/
public class Regexp {
private final JavaScriptObject regexp;
public Regexp(String pattern) {
this.regexp = compile(pattern);
}
public Regexp(String pat, String flags) {
this.regexp = compileFlags(pat, flags);
}
public static native JavaScriptObject compile(String pat) /*-{
return new RegExp(pat);
}-*/;
public static native JavaScriptObject compileFlags(String pat, String flags) /*-{
return new RegExp(pat, flags);
}-*/;
public JSArray exec(String str) {
return exec0(regexp, str);
}
private static native JSArray exec0(JavaScriptObject regexp, String str) /*-{
return regexp.exec(str);
}-*/;
public JSArray match(String currentRule) {
return match0(regexp, currentRule);
}
private native JSArray match0(JavaScriptObject regexp, String currentRule)/*-{
return currentRule.match(regexp);
}-*/;
public boolean test(String rule) {
return test0(regexp, rule);
}
private native boolean test0(JavaScriptObject regexp, String rule) /*-{
return regexp.test(rule);
}-*/;
public static JSArray match(String regexp, String flags, String string) {
return new Regexp(regexp, flags).match(string);
}
}
|