txt: ## subst.md
  subst
  
  Combined from primary sources listed below.
  
  # [In Str](#___top "go to top of document")[§](#(Str)_method_subst "direct link")
  
  See primary documentation
  [in context](/type/Str#method_subst)
  for **method subst**.
  
  ```raku
  multi method subst(Str:D: $matcher, $replacement = "", *%options)
  ```
  
  Returns the invocant string where `$matcher` is replaced by `$replacement` (or the original string, if no match was found). If no `$replacement` is provided, the empty string is used (i.e., matched string(s) are removed).
  
  There is an in-place syntactic variant of `subst` spelled `s/matcher/replacement/` and with adverb following the `s` or inside the matcher.
  
  `$matcher` can be a [`Regex`](/type/Regex), or a literal `Str`. Non-Str matcher arguments of type [`Cool`](/type/Cool) are coerced to `Str` for literal matching. If a [`Regex`](/type/Regex) `$matcher` is used, the [`$/` special variable](/syntax/$$SOLIDUS) will be set to [`Nil`](/type/Nil) (if no matches occurred), a [`Match`](/type/Match) object, or a [`List`](/type/List) of [`Match`](/type/Match) objects (if multi-match options like `:g` are used).
  
  # [In Allomorph](#___top "go to top of document")[§](#(Allomorph)_method_subst "direct link")
  
  See primary documentation
  [in context](/type/Allomorph#method_subst)
  for **method subst**.
  
  ```raku
  method subst(Allomorph:D: |c)
  ```
  
  Calls [`Str.subst`](/type/Str#method_subst) on the invocant's [`Str`](/type/Str) value.
  
  # [In Cool](#___top "go to top of document")[§](#(Cool)_method_subst "direct link")
  
  See primary documentation
  [in context](/type/Cool#method_subst)
  for **method subst**.
  
  ```raku
  method subst(|)
  ```
  
  Coerces the invocant to [`Stringy`](/type/Stringy) and calls [Str.subst](/type/Str#method_subst).
  