Class RegexPatternUtils

java.lang.Object
org.dspace.app.util.RegexPatternUtils

public class RegexPatternUtils extends Object
Utility class useful for check regex and patterns.
Author:
Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
  • Field Details

  • Method Details

    • computePattern

      public static final Pattern computePattern(String regex) throws PatternSyntaxException
      Computes a pattern starting from a regex definition with flags that uses the standard format: /{regex}/{flags} (ECMAScript format). This method can transform an ECMAScript regex into a java Pattern object which can be used to validate strings.
      If regex is null, empty or blank a null Pattern will be retrieved If it's a valid regex, then a non-null Pattern will be retrieved, an exception will be thrown otherwise.
      Parameters:
      regex - with format /{regex}/{flags}
      Returns:
      Pattern regex pattern instance
      Throws:
      PatternSyntaxException