Class PatternReplaceVar


public class PatternReplaceVar extends MultipartVar
A transformational variable resolver that replaces matched patterns with given characters.

The format for this var is:

  • "$PR{stringArg,pattern,replace}"

The pattern can be any string optionally containing '*' or '?' representing any or one character respectively. The replace can contain matched regex sub classes like \$1, \$2 ..

Example:

// Create a variable resolver that resolves system properties and $SW vars. VarResolver varResolver = VarResolver.create().vars(PatternReplaceVar.class, SystemPropertiesVar.class).build(); // Use it! System.out.println(varResolver.resolve("Java version=$PR{$S{java.version}, (_([0-9]+)), \\ build=\\$2}"));

Since this is a MultipartVar, any variables contained in the result will be recursively resolved.
Likewise, if the arguments contain any variables, those will be resolved before they are passed to this var.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • resolve

      public String resolve(VarResolverSession session, String[] args)
      Description copied from class: MultipartVar
      The interface that needs to be implemented for this interface.
      Specified by:
      resolve in class MultipartVar
      Parameters:
      session - The session object used for a single instance of a string resolution.
      args - The arguments inside the variable.
      Returns:
      The resolved variable.