Class StringUtils.Rewriter

java.lang.Object
com._1c.g5.v8.dt.common.StringUtils.Rewriter
Enclosing class:
StringUtils

public abstract static class StringUtils.Rewriter extends Object
A matcher-based string rewriter.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a rewriter using the given regular expression; the syntax is the same as for 'Pattern.compile'.
  • Method Summary

    Modifier and Type
    Method
    Description
    group(int i)
    Returns the input subsequence captured by the given group during the previous match operation.
    abstract String
    Overridden to compute a replacement for each match.
    Returns the result of rewriting 'original' by invoking the method 'replacement' for each match of the regular expression supplied to the constructor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Rewriter

      public Rewriter(String regex)
      Constructs a rewriter using the given regular expression; the syntax is the same as for 'Pattern.compile'.
      Parameters:
      regex - Regular expression to find substrings to replace
  • Method Details

    • group

      public String group(int i)
      Returns the input subsequence captured by the given group during the previous match operation.
      Parameters:
      i - Group number
      Returns:
      Subsequence by number
    • replacement

      public abstract String replacement()
      Overridden to compute a replacement for each match. Use the method 'group' to access the captured groups.
      Returns:
      The string that will replace the current group found by the matcher
    • rewrite

      public String rewrite(CharSequence original)
      Returns the result of rewriting 'original' by invoking the method 'replacement' for each match of the regular expression supplied to the constructor.
      Parameters:
      original - The character sequence to be rewritten
      Returns:
      Rewritten sequence as a string