Class PatternTemplate

java.lang.Object
org.forgerock.openig.regex.PatternTemplate

public class PatternTemplate extends Object
Expresses a transformation to be applied to a regular expression pattern match. A template may contain references to groups captured in the match. Each occurrence of $g will be substituted by capture group g in a match result. A dollar sign or numeral literal immediately following a capture group reference may be included as a literal in the template by preceding it with a backslash (\). Backslash itself must be also escaped in this manner.
  • Constructor Details

    • PatternTemplate

      public PatternTemplate(String value)
      Constructs a new template with the specified value.
      Parameters:
      value - the template to apply to regular expression pattern matches.
  • Method Details

    • applyTo

      public String applyTo(MatchResult result)
      Performs a transformation of a match result by applying the template. References to matching groups that are not in the match result resolve to a blank ("") value.
      Parameters:
      result - the match result to apply the template to.
      Returns:
      the value of the matching result with the template applied.
    • toString

      public String toString()
      Returns the literal template value.
      Overrides:
      toString in class Object
      Returns:
      the literal template value.