com.github.fge.jsonschema.core.util
Class RhinoHelper

java.lang.Object
  extended by com.github.fge.jsonschema.core.util.RhinoHelper

@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:

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


Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

regexIsValid

public static boolean regexIsValid(String regex)
Validate that a regex is correct

Parameters:
regex - the regex to validate
Returns:
true if the regex is valid

regMatch

public 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)).

Parameters:
regex - the regex to use
input - the input to match against (and again, see description)
Returns:
true if the regex matches the input