TM U      !"#$%&'()*+,-./0123456789:;<=>?@AB C D E F G H I J K L M N O P Q R S T Safe &)-3457N+pad String with Char to total length of Int pad on leftpad '-' 5 "abc" "--abc"  pad on rightpad' '-' 5 "abc""abc--" UUNone &)-3457NVWVWNone &)-3457N X Y Z [\]^_`a bc     bcSafe &)-3457Nboth Ascii and Utf8both Ascii and Utf8None &)-3457Nmay be omitted-if both Once and All are passed, All prevails!Offset, Length$Haystack&Needle*#content with some replacements made+Sposition adjustment: group replacement length may differ from replaced text length  !"#$%&'()*+,-./0 !"#$%&'()*+,-,-()*+&'$%"#! 0/.  !"#$%&'()*+,-./0 None &)-3457Ndmatch offset, lengthe all groupsfmatches for one groupdefdefdef None &)-3457Nghijmatched contentkmatched contentlmghijkghijklmNone &)-3457N12 covers all result typesGcompiler looks up the appropriate function depending on the result type3 is borrowed from Text.Regex.PCRE.Wrap, is a short version of 2 See also Text.Regex.Do.Pcre.MatchSame 4tweak Regex with optionsn match allo match once "8" =~ "1K205B 8 EC65"::[PosLen][(13,2)]Utf8Text.Regex.Do.Pcre.MatchSame p match all6"well" =~ "all is well that ends well"::[[ByteString]][["well"],["well"]]Text.Regex.Do.Pcre.MatchSame qtest"2" =~ "B8E> 2 ;5AC"::BoolTrueText.Regex.Do.Pcre.MatchSame r match once""^all" =~ "all the time"::[String]["all"]Text.Regex.Do.Pcre.MatchSame 123patternbody4nopqr123412341234nopqrNone &)-3457N5dynamic group replace,custom replacer fn returns replacement valuereplacer::GroupReplacer String' replacer = defaultReplacer 1 tweak1* where tweak1 str1 = case str1 of5 "101" -> "[AB> >48=]"0 "3" -> "[three]"; otherwise -> trace str1 "?" vs  optionsNreplace [Once,Utf8] (Pattern "\\w=(\\d{1,3})", replacer) $ Body "a=101 b=3 12""a=[AB> >48=] b=3 12"Mreplace [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 s replacement see Text.Regex.Do.SplitPreplace [Once,Utf8] (Pattern "<5=55", Replacement "1>;55") $ Body "<5=55 <5=55" "1>;55 <5=55"Mreplace [Once,Utf8] (Pattern "^a\\s", Replacement "A") $ Body "a bc E>;.3>@.""Abc E>;.3>@." 8dReplaces specified (by idx) group match with tweaked value. Works for one common simple use case,# can be used with complicated regex*another custom dynamic replacer could e.g.?inspect all group matches before looking up a replacement. 9get group content safelysee 8 source for use example:call from your custom , passed to  replaceGroupsee 8 source for use example tuvwxyz567{|}~8 group idx"(group match -> replacement) tweak9:replaceable, unadjusted(new val, acc passed to ,)new acc  56789:  56:897tuvwxyz567{|}~89:None &)-3457N<needle between parts disappears=#needle sticks to front of next part>%needle sticks to end of previous part?;replace (Pattern "\n") (Replacement ",") (Body "a\nbc\nde")"a,bc,de" @,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") A)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"] ;<=>?@A;<=>?@A@?A;<=> ;<=>?@A 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" BCBCBC BC None &)-3457NDpicks 1 instance where & and $ are of the same typespecify either & or $ + out typeshandy when working with OverloadedStrings,("^all"::String) -~ "all the time"::[String] ["all"] DEFpatternbody- in (F) is the minus signGHIJKLMNOPDEF DEFPONMLKJIHG DEFGHIJKLMNOP None &)-3457NQ/removes leading and trailing spaces and tabs QRSTQRQRTSQRST !"#$%&'()*+,-./#"011223344567789:;<=>?@ABCDEFGH@IJ K L M N O P Q R S T U V W X Y Z [ \ ]^_`abcdefghijkl m n o p q r s t u vwxyz{|}~%  regex_BjRyKp3eOMzFHQ6uK6IglwText.Regex.Do.TypeRegexText.Regex.Do.Pcre.MatchText.Regex.Do.PadText.Regex.Do.Pcre.OptionText.Regex.Do.ConvertText.Regex.Do.TypeDoText.Regex.Do.Pcre.ReplaceText.Regex.Do.SplitText.Regex.Do.FormatText.Regex.Do.Pcre.MatchSameText.Regex.Do.TrimText.Regex.Do.Pcre.ResultText.Regex.Do.Pcre.Matchfregex_47KXx9dLqeO8MNJeizLKhPText.Regex.Base.RegexLike MatchArrayextractregex_D90DoxwgsTHEvoLrkciZPUText.Regex.PCRE.Wrap CompOption ExecOptionRegexpadpad'ExecBlankENotEmptyPartialCompBlankAnchoredCaselessDotall MultilineUtf8Ungreedycompexec toByteStringtoStringRegex_r_Rx_Opt_ ReplaceCaseOnceAllPosLen ReplacementBodyPattern ReplaceAccaccpos_adj GroupReplacer $fRegex_Regex $fRegex_[]$fRegex_ByteStringMatchmatch=~ makeRegexOptsReplacereplaceMr_defaultReplacergetGroup replaceMatch KeepNeedleDropFrontEndbreaksplitFormatformat MatchSamematch'-~$fMatchSameByteString[]$fMatchSameByteString[]0$fMatchSameByteString[]1$fMatchSameByteString[]2$fMatchSameByteStringBool$fMatchSame[][]$fMatchSame[][]0$fMatchSame[][]1$fMatchSame[][]2$fMatchSame[]BoolTrimtrim$fTrim[]$fTrimByteStringpad_RegexSRegexB execBlank execNotEmpty execPartial compBlank compAnchored compCaseless compDotAll compMultilinecompUTF8 compUngreedycompOptexecOptposlen allMatches groupMatchMatchfmarray_poslen_onceall $fMatchf[]ab$fMatchfMaybeab $fMatchab[] $fMatchab[]0 $fMatchab[]1 $fMatchabBool $fMatchab[]2bytes_6VWy06pWzJq9evDvK2d4w6Data.ByteString.Internal ByteStringReplace_prefixsuffixconcat'len' toByteString'toAreplace_replaceGroncerall firstGroup adjustPoslen ronceGroup rallGroupaddOptisUtf8$fReplace_ByteString $fReplace_[] $fReplaceGroupReplacerByteString$fReplaceGroupReplacer[]$fReplaceReplacementByteString$fReplaceReplacement[]break' breakFrontbreakEndsplit'splitEnd splitFront checkPattern $fFormat[] $fFormat[]0 CustomerFn foldFn_idx foldFn_map replaceOne foldr_idxfoldFn