@ThreadSafe 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 | 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.
|
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)