Package com._1c.g5.v8.dt.common
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
Amatcher
-based string rewriter.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
group(int i)
Returns the input subsequence captured by the given group during the previous match operation.abstract String
replacement()
Overridden to compute a replacement for each match.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.
-
-
-
Constructor Detail
-
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 Detail
-
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
-
-