c([d      !"#$%&'()*+,-./0123456789:;<=> ? @ A B C D E F GHIJK L M N O P Q R S T U V W X Y Z [ \ ] ^ _ `abcSafe &)-3457N+pad String with Char to total length of Int pad on leftpad '-' 5 "abc" "--abc"  pad on rightpad' '-' 5 "abc""abc--" ddNone &)-3457NefefNone &)-3457N g h i jklmnop qr     qrNone &)-3457Nmay be omitted-if both Once and All are passed, All prevailsOffset, LengthHaystack!Needle%#content with some replacements made&Sposition adjustment: group replacement length may differ from replaced text length 'see Text.Regex.Do.Pcre.ReplaceOpen defaultReplacer for example implementation !"#$%&'( !"#$%&'('(#$%&!"  !"#$%&'(None &)-3457N+both Ascii and Utf8,both Ascii and Utf8)*+,-.)*+,+,)*.-)*+,-.None &)-3457N/01234/0101432//01234None &)-3457N5<see String, ByteString instances for implementation examplessee Text.Regex.Base.RegexLike for s detail 56789:;<=56789 567=<;:8956789:;<= None &)-3457N?needle between parts disappears@#needle sticks to front of next partA%needle sticks to end of previous partB;replace (Pattern "\n") (Replacement ",") (Body "a\nbc\nde")"a,bc,de" C,break Drop (Pattern "\n") (Body "a\nbc\nde")("a", "bc\nde")-break Front (Pattern "\n") (Body "a\nbc\nde")("a", "\nbc\nde")+break End (Pattern "\n") (Body "a\nbc\nde")("a\n", "bc\nde") D)split Drop (Pattern " ") (Body "a bc de")["a", "bc", "de"]space may be used-split Front (Pattern "\n") (Body "a\nbc\nde")["a", "\nbc", "\nde"]+split End (Pattern "\n") (Body "a\nbc\nde")["a\n", "bc\n", "de"] >?@ABCtuvDwxyz>?@ABCDCBD>?@A >?@ABCtuvDwxyz None &)-3457N{ key basedkey may be {any string};format ">2G8=:0 {a} =5 {b}" [("a","2K45;:8"),("b","AB>8B")]">2G8=:0 2K45;:8 =5 AB>8B"| index based2format "=0 ?5@2>5 {0}, =0 2B>@>5 {0}" ["?5@;>2:0"]("=0 ?5@2>5 ?5@;>2:0, =0 2B>@>5 ?5@;>2:0"*format "Polly {0} a {1}" ["got","cracker"]"Polly got a cracker" }EF~{|EFEF }EF~{|None &)-3457Nmatch offset, length all groupsmatches for one groupNone &)-3457Nmatched contentmatched contentNone &)-3457NGH covers all result typesGcompiler looks up the appropriate function depending on the result typeI is borrowed from Text.Regex.PCRE.Wrap, is a short version of H See also Text.Regex.Do.Pcre.MatchSame Jtweak Regex with options match all match once "8" =~ "1K205B 8 EC65"::[PosLen][(13,2)]Utf8Text.Regex.Do.Pcre.MatchSame  match all6"well" =~ "all is well that ends well"::[[ByteString]][["well"],["well"]]Text.Regex.Do.Pcre.MatchSame test"2" =~ "B8E> 2 ;5AC"::BoolTrueText.Regex.Do.Pcre.MatchSame  match once""^all" =~ "all the time"::[String]["all"]Text.Regex.Do.Pcre.MatchSame GHIpatternbodyJGHIJGHIJGHIJ None &)-3457NKpicks G instance where ! and  are of the same typespecify either ! or  + out typeshandy when working with OverloadedStrings,("^all"::String) -~ "all the time"::[String] ["all"] KLMpatternbody- in (M) is the minus signNOPQRSTUVWKLM KLMWVUTSRQPON KLMNOPQRSTUVW None &)-3457NX:Sreplace (Just [(4,3)::PosLen]) (Replacement "4567") (Body "abc 123 def"::Body Text)"abc 4567 def"' :replacer::GroupReplacer TextJ replacer = defaultReplacer 1 tweak1 -- 1: first match in group* where tweak1 str1 = case str1 of2 "123" -> "[1-2-3]"? otherwise -> traceShow str1 "?"Qreplace (Just ([(4,3),(8,2)]::[PosLen])) replacer (Body "abc 123 def"::Body Text)"abc [1-2-3] def" ZdReplaces specified (by idx) group match with tweaked value. Works for one common simple use case'# can be used with complicated regexnanother custom dynamic replacer could e.g. inspect all group matches before looking up a replacement. [get group content safelysee Z source for use example\call from your custom ' passed to  replaceGroupsee Z source for use example XYZ group idx"(group match -> replacement) tweak[\replaceable, unadjusted(new val, acc passed to ')new accXYZ[\XYZ[\ XYZ[\ None &)-3457N]%implementation detail for the curious_dynamic group replace2custom replacer fn returns replacement value. See Zreplacer::GroupReplacer String' replacer = defaultReplacer 1 tweak1* where tweak1 str1 = case str1 of5 "101" -> "[AB> >48=]"0 "3" -> "[three]"; otherwise -> trace str1 "?" vs  optionsMreplace [Once,Utf8] (Pattern "\\w=(\\d{1,3})") replacer $ Body "a=101 b=3 12""a=[AB> >48=] b=3 12"Lreplace [All,Utf8] (Pattern "\\w=(\\d{1,3})") replacer $ Body "a=101 b=3 12""a=[AB> >48=] b=[three] 12"+static replace for simple (no group) needle for no-regex  replacement see Text.Regex.Do.SplitQreplace [Once,Utf8] (Pattern "<5=55") (Replacement "1>;55") $ Body "<5=55 <5=55" "1>;55 <5=55"Nreplace [Once,Utf8] (Pattern "^a\\s") (Replacement "A") $ Body "a bc E>;.3>@.""Abc E>;.3>@." ]^_]^__]^ ]^_None &)-3457N`/removes leading and trailing spaces and tabs `abc`a`acb`abc !"#$%&'()*+,-&%.//00112234556789:;<=>?@ABCDEFGHIJ K L M N O P Q R STUVW X Y Z [ \ ] ^ _ ` a b c d e O f g h i j Oklmnopqrstuvwxyz{|}~     ( regex_C6D4ZU0eafj8qAe91dA0OTText.Regex.Do.Type.ReexportText.Regex.Do.Pcre.MatchText.Regex.Do.PadText.Regex.Do.Pcre.OptionText.Regex.Do.Type.DoText.Regex.Do.ConvertText.Regex.Do.Type.Regex_Text.Regex.Do.Type.ExtractText.Regex.Do.SplitText.Regex.Do.FormatText.Regex.Do.Pcre.MatchSameText.Regex.Do.Pcre.ReplaceOpenText.Regex.Do.Pcre.ReplaceText.Regex.Do.TrimText.Regex.Do.Pcre.ResultText.Regex.Do.Pcre.Matchfregex_47KXx9dLqeO8MNJeizLKhPText.Regex.Base.RegexLike MatchArrayextractregex_D90DoxwgsTHEvoLrkciZPUText.Regex.PCRE.Wrap CompOption ExecOptionRegexpadpad'ExecBlankENotEmptyPartialCompBlankAnchoredCaselessDotall MultilineUtf8UngreedycompexecOpt_ ReplaceCaseOnceAllPosLen ReplacementBodyPattern ReplaceAccaccpos_adj GroupReplacerToArraytoArray toByteStringtoString $fToArray[]$fToArrayArrayRx_Regex_r_ $fRegex_Regex $fRegex_[]$fRegex_ByteStringExtract'concat'len'prefixsuffix$fExtract'Text $fExtractText$fExtract'ByteString $fExtract'[] KeepNeedleDropFrontEndreplacebreaksplitFormatformatMatchmatch=~ makeRegexOpts MatchSamematch'-~$fMatchSameByteString[]$fMatchSameByteString[]0$fMatchSameByteString[]1$fMatchSameByteString[]2$fMatchSameByteStringBool$fMatchSame[][]$fMatchSame[][]0$fMatchSame[][]1$fMatchSame[][]2$fMatchSame[]Bool ReplaceOpendefaultReplacergetGroup replaceMatch ReplaceCase_replace_Trimtrim$fTrim[]$fTrimByteStringpad_RegexSRegexB execBlank execNotEmpty execPartial compBlank compAnchored compCaseless compDotAll compMultilinecompUTF8 compUngreedycompOptexecOptExtractbreak' breakFrontbreakEndsplit'splitEnd splitFront checkPattern $fFormat[] $fFormat[]0 CustomerFn foldFn_idx foldFn_map replaceOne foldr_idxfoldFnposlen allMatches groupMatchMatchfmarray_poslen_onceall $fMatchf[]ab$fMatchfMaybeab $fMatchab[] $fMatchab[]0 $fMatchab[]1 $fMatchabBool $fMatchab[]2 firstGroup adjustPoslen$fReplaceOpen[]GroupReplacer$fReplaceOpenMaybeGroupReplacer$fReplaceOpen[]Replacement$fReplaceOpenMaybeReplacementbytes_6VWy06pWzJq9evDvK2d4w6Data.ByteString.Internal ByteStringvanilla_replaceaddOpt$fReplaceCase_GroupReplacer[]%$fReplaceCase_GroupReplacerByteString#$fReplaceCase_ReplacementByteString$fReplaceCase_Replacement[]