```{index} single: substitute (Peta::PCRE2) ``` ```{index} single: Peta::PCRE2::substitute ``` # substitute Replace matches of the pattern in a subject, returning a new string. Global by default (`PCRE2_SUBSTITUTE_GLOBAL`); pass an explicit `$options` value to override; it replaces the default rather than adding to it, so include `PCRE2_SUBSTITUTE_GLOBAL` yourself if you still want all occurrences. The replacement uses PCRE2 substitution syntax (`$1`, `${name}`; `\` escapes with `PCRE2_SUBSTITUTE_EXTENDED`). The subject is not modified, and a UTF8-flagged subject yields a UTF8-flagged result. ## Synopsis ```perl my $clean = Peta::PCRE2->new(">.*\\n|\\n")->substitute($fasta, ""); ```