public final class RhinoHelper extends Object
ECMA 262 validation helper. Rhino is used instead of
java.util.regex because the latter doesn't comply with ECMA 262:
Pattern.DOTALL;++,
?+, etc);\b;
\< (for beginning of word) and \> (for end
of word) are not understood.
And many, many other things. See here for the full story. And if you don't yet have Jeffrey Friedl's "Mastering regular expressions", just buy it :p
| Modifier and Type | Field and Description |
|---|---|
private static org.mozilla.javascript.Context |
ctx
Script context to use
|
private static String |
jsAsString
JavaScript scriptlet defining functions
regexIsValid
and regMatch |
private static org.mozilla.javascript.Function |
regexIsValid
Reference to Javascript function for regex validation
|
private static org.mozilla.javascript.Function |
regMatch
Reference to Javascript function for regex matching
|
private static org.mozilla.javascript.Scriptable |
scope
Script scope
|
| Modifier | Constructor and Description |
|---|---|
private |
RhinoHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
regexIsValid(String regex)
Validate that a regex is correct
|
static boolean |
regMatch(String regex,
String input)
Matches an input against a given regex, in the real sense
of matching, that is, the regex can match anywhere in the input.
|
private static final String jsAsString
regexIsValid
and regMatchprivate static final org.mozilla.javascript.Context ctx
private static final org.mozilla.javascript.Scriptable scope
private static final org.mozilla.javascript.Function regexIsValid
private static final org.mozilla.javascript.Function regMatch
public static boolean regexIsValid(String regex)
regex - the regex to validatepublic static boolean regMatch(String regex, String input)
Matches an input against a given regex, in the real sense
of matching, that is, the regex can match anywhere in the input.
Java's java.util.regex makes the unfortunate mistake to make
people believe that matching is done on the whole input... Which is
not true.
Also note that the regex MUST have been validated at this point
(using regexIsValid(String)).
regex - the regex to useinput - the input to match against (and again, see description)Copyright © 2012. All Rights Reserved.