úÎQQIĞ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 Intpad '-' 5 "abc" "--abc" pad' '-' 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  !"#$%&'()*+,-./ !"#$%&'()*+,,()*+&'$%"#! /.-  !"#$%&'()*+,-./ None &)-3457Ndmatch offset, lengthe all groupsfmatches for one groupdefdefdef None &)-3457Nghijmatched contentkmatched contentlmghijkghijklmNone &)-3457N01 covers all result typesGcompiler looks up the appropriate function depending on the result type2 is borrowed from Text.Regex.PCRE.Wrap, is a short version of 1 See also Text.Regex.Do.Pcre.MatchSame 3tweak 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 0123nopqr012301230123nopqrNone &)-3457N4dynamic 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  optionsSreplaceGroup [Once,Utf8] (Pattern "\\w=(\\d{1,3})", replacer) $ Body "a=101 b=3 12""a=[AB> >48=] b=3 12"RreplaceGroup [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) needlePreplace [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>@." 8Byou can write a custom replacer. This is only one common use case.@Replaces specified (by idx) group match with tweaked value. 9get group content safelycall from your custom , passed to 6:call from your custom , passed to 6see example replacer above stuvwxy4567z{|8 group idx"(group match -> replacement) tweak9}~:replaceable, unadjusted(new val, acc passed to ,)new acc€‚ƒ„…†  456789:  456:897stuvwxy4567z{|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" BC‘’“”•ŽBCBC BC‘’“”•Ž None &)-3457NDpicks 0 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– !"#$%&'()*+,-./#"01122334456789:;<=>?@ABCDEFGHI@JK L M N O P Q R S T U V W X Y Z [ \ ] ^_`abcdefghijklm n o p q r s t u v wxyz{|}~€‚ƒ„…†‡ˆ‰Š%‹ŒŽ‘’“”•– — ˜ ™ š › œ  žŸregex_CFn7k9CNNJeFCVIu4i2rIuText.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=~ makeRegexOptsReplacereplace replaceGroupMr_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[]2Replace_prefixsuffixconcat'len' toByteString'toAroncerall firstGroup adjustPoslen ronceGroup rallGroupaddOptisUtf8$fReplace_ByteString $fReplace_[]$fReplaceByteString $fReplace[]break' breakFrontbreakEndsplit'splitEnd splitFront checkPattern $fFormat[] $fFormat[]0 CustomerFn foldFn_idx foldFn_map replaceOne foldr_idxfoldFn