Class PatternUtils

java.lang.Object
com.blackrook.rookscript.struct.PatternUtils

public final class PatternUtils extends Object
A caching structure for all RegEx patterns.

RegExs, when compiled into Patterns, can be reused several times. This cache is for automatic building/returning existing patterns by String.

All operations are thread-safe.

Author:
Matthew Tropiano
  • Method Details

    • get

      public static Pattern get(String regex)
      Gets an existing, compiled pattern or a newly-compiled one for the provided expression. Also useful for pre-warming oft-used expressions.
      Parameters:
      regex - the input RegEx.
      Returns:
      a newly-compiled Pattern or an existing one.
      Throws:
      PatternSyntaxException - if the expression cannot be compiled.