edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule

## Class RegexReplacementRule

- java.lang.Object
- - edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule.AbstractRegexReplacementRule
  - - edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule.RegexReplacementRule

- All Implemented Interfaces:
    WordRule

      public class RegexReplacementRule
      extends AbstractRegexReplacementRule

  A rule specified using a regular expression and a replacement string.

  Original code written by Tom White under the Apache v2 license. Modified by Philip R. Burns for integration into MorphAdorner.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `replacement`

    - ### Fields inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule.AbstractRegexReplacementRule

      `pattern`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RegexReplacementRule(java.lang.String regex, java.lang.String replacement)` Construct a rule using the given regular expression and replacement string.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `replace(java.util.regex.Matcher matcher)` Use the state in the given `Matcher` to perform a replacement.

    - ### Methods inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule.AbstractRegexReplacementRule

      `applies, apply, disjunction, disjunction`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### replacement

          protected final java.lang.String replacement

  - ### Constructor Detail

    - #### RegexReplacementRule

          public RegexReplacementRule(java.lang.String regex,
                              java.lang.String replacement)

      Construct a rule using the given regular expression and replacement string.
      Parameters:
        `regex` - The regular expression used to match words.
        `replacement` - The replacement string.

        The replacement string may contain references to subsequences captured matching. See `Matcher.appendReplacement(java.lang.StringBuffer, java.lang.String)`.

  - ### Method Detail

    - #### replace

          public java.lang.String replace(java.util.regex.Matcher matcher)

      Description copied from class: `AbstractRegexReplacementRule`
      Use the state in the given `Matcher` to perform a replacement.
      Specified by:
        `replace` in class `AbstractRegexReplacementRule`
      Parameters:
        `matcher` - The matcher used to match the word.
      Returns:
        The transformed word.