class_docstr: Performs a regular expression substitution on the token text.
  
  This is especially useful for removing text from tokens, for example
  hyphens::
  
      ana = RegexTokenizer(r"\S+") | SubstitutionFilter("-", "")
  
  Because it has the full power of the re.sub() method behind it, this filter
  can perform some fairly complex transformations. For example, to take
  tokens like ``'a=b', 'c=d', 'e=f'`` and change them to ``'b=a', 'd=c',
  'f=e'``::
  
      # Analyzer that swaps the text on either side of an equal sign
      rt = RegexTokenizer(r"\S+")
      sf = SubstitutionFilter("([^/]*)/(./*)", r"\2/\1")
      ana = rt | sf
class_docstr_tok: ["Performs","a","regular","expression","substitution","on","the","token","text",".","This","is","especially","useful","for","removing","text","from","tokens",",","for","example","hyphens",":",":","ana","=","RegexTokenizer","(","r","''","\\S+","''",")","|","SubstitutionFilter","(","``","-","''",",","``","''",")","Because","it","has","the","full","power","of","the","re.sub","(",")","method","behind","it",",","this","filter","can","perform","some","fairly","complex","transformations",".","For","example",",","to","take","tokens","like","``","'","a=b","'",",","'","c=d","'",",","'","e=f","'","``","and","change","them","to","``","'","b=a","'",",","'d=c","'",",","'","f=e","'","``",":",":","#","Analyzer","that","swaps","the","text","on","either","side","of","an","equal","sign","rt","=","RegexTokenizer","(","r","''","\\S+","''",")","sf","=","SubstitutionFilter","(","``","(","[","^\/","]","*",")","\/","(",".\/","*",")","''",",","r","''","\\2\/\\1","''",")","ana","=","rt","|","sf"]
docstr: :param pattern: a pattern string or compiled regular expression object
      describing the text to replace.
  :param replacement: the substitution text.
code: def __init__(self, pattern, replacement):
      """
      :param pattern: a pattern string or compiled regular expression object
          describing the text to replace.
      :param replacement: the substitution text.
      """
  
      self.pattern = rcompile(pattern)
      self.replacement = replacement
  
imports: from itertools import chain
  from whoosh.compat import next
  from whoosh.analysis.acore import Composable
  from whoosh.util.text import rcompile
label_desc: Use image node_id 1 to create a new SubstitutionFilter object from inherited base classes: Filter with example: obj = SubstitutionFilter(pattern, replacement)