: Class PerlSubstitution

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jregex
Class PerlSubstitution

    java.lang.Object
      |
      +--jregex.PerlSubstitution

All Implemented Interfaces:
  Substitution

public class PerlSubstitution
extends java.lang.Object
implements Substitution

An implementation of the Substitution interface. Performs substitutions in accordance with Perl-like substitution scripts.
The latter is a string, containing a mix of memory register references and plain text blocks.
It may look like "some_chars $1 some_chars$2some_chars" or "123${1}45${2}67".
A tag consisting of '$',not preceeded by the escape character'\' and followed by some digits (possibly enclosed in the curled brackets) is interpreted as a memory register reference, the digits forming a register ID. All the rest is considered as a plain text.
Upon the Replacer has found a text block that matches the pattern, a references in a replacement string are replaced by the contents of corresponding memory registers, and the resulting text replaces the matched block.
For example, the following code:

     System.out.println("\""+
        new Replacer(new Pattern("\\b(\\d+)\\b"),new PerlSubstitution("'$1'")).replace("abc 123 def")
        +"\"");

will print `"abc '123' def"`.

See Also:
  `Substitution`, `Replacer`, `Pattern`

Constructor Summary
`PerlSubstitution(java.lang.String s)`

Method Summary
`void` | `appendSubstitution(MatchResult match, TextBuffer dest)`
`java.lang.String` | `toString()`
`java.lang.String` | `value(MatchResult mr)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### PerlSubstitution

    public PerlSubstitution(java.lang.String s)

Method Detail

### value

    public java.lang.String value(MatchResult mr)

### appendSubstitution

    public void appendSubstitution(MatchResult match,
                                   TextBuffer dest)

  Specified by:
    `appendSubstitution` in interface `Substitution`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD