!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[ \ ] ^ _ ` a b c d e f g h i j k l m n o p qrst u v w x y z { | } ~  Safe&)-3457>LN+pad String with Char to total length of Int pad on leftpad '-' 5 "abc" "--abc"  pad on rightpad' '-' 5 "abc""abc--" None&)-3457>LNNone&)-3457>LN Dclears default options: extended,caseSensitive,multiline regex An empty string is not considered to be a valid match if this option is set. If there are alternatives in the pattern, they are tried. If all the alternatives match the empty string, the entire match fails. For example, if the patterna?b?is applied to a string not beginning with "a" or "b", it matches an empty string at the start of the subject. With PCRE_NOTEMPTY set, this match is not valid, so PCRE searches further into the string for occurrences of "a" or "b". see PCREPARTIAL(3) in  http://www.pcre.org/pcre.txtpcre man pages  http://www.pcre.org/pcre.txtpcre man pages >clears default options: extended,caseSensitive,multiline regexthe pattern is forced to be "anchored", that is, it is constrained to match only at the first matching point in the string that is being searched (the "subject string").TThis effect can also be achieved by appropriate constructs in the pattern itself. Bletters in the pattern match both upper and lower case letters.jIt is equivalent to Perl's /i option, and it can be changed within a pattern by a (?i) option setting.In UTF-8 mode, PCRE always understands the concept of case for characters whose values are less than 128, so caseless matching is always possible. For characters with higher values, the concept of case is supported if PCRE is compiled with Unicode property support. If you want to use caseless matching for characters 128 and above, you must ensure that PCRE is compiled with Unicode property support as well as with UTF-8 support. ya dot metacharacter in the pattern matches a character of any value, including one that indicates a newline.SHowever, it only ever matches one character, even if newlines are coded as CRLF.\Without this option, a dot does not match when the current position is at a newline.pThis option is equivalent to Perl's /s option, and it can be changed within a pattern by a (?s) option setting.lA negative class such as [^a] always matches newline characters, independent of the setting of this option. By default, for the purposes of matching "start of line" and "end of line", PCRE treats the subject string as consisting of a single line of characters, even if it actually contains newlines. The "start of line" metacharacter (^) matches only at the start of the string, and the "end of line" metacharacter ($) matches only at the end of the string, or before a terminating newline (except when PCRE_DOLLAR_ENDONLY is set). Note, however, that unless PCRE_DOTALL is set, the "any character" metacharacter (.) does not match at a newline. This behaviour (for ^, $, and dot) is the same as Perl.When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs match immediately following or immediately before internal newlines in the subject string, respectively, as well as at the very start and end.oThis is equivalent to Perl's /m option, and it can be changed within a pattern by a (?m) option setting.If there are no newlines in a subject string, or no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect. This option causes PCRE to regard both the pattern and the subject as strings of UTF-8 characters instead of single-byte strings. However, it is available only when PCRE is built to include UTF support. If not, the use of this option provokes an error. Details of how this option changes the behaviour of PCRE are given in the pcreunicode page. This option inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by "?".AIt can also be set by a (?U) option setting within the pattern.       Safe&)-3457>LNalloncematch / replace all match / replace once"test: does body match pattern? !"#$%&'()* !"#!" *)('&%$# !"#$%&'()*Safe&)-3457>LN .2does not do any codec. Plain wrap / unwrap newtype2values3Offset, Length6Haystack8Needle<#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 implementationC2does not do any codec. Plain wrap / unwrap newtype+,-./0123456789:;<=>?@ABCDEFG+,-./0123456789:;<=>?>?:;<=G89F67E45D312C./0+,-BA@+,-./0123456789:;<=>?@ABCDEFGSafe&)-3457>LNJboth Ascii and Utf8Lboth Ascii and Utf8HIJKLMNHIJKLJKLHINMHIJKLMNNone&)-3457>LNOcatches regex construction errors TmonadicVX#let catch regex construction errorsfor m to catch errors, implement  in mdefault m implementation: OmakeRegexM test case:it "RegexResult test case" $ do$ rx1 `shouldNotSatisfy` isok1! rx2 `shouldSatisfy` isok1@ where rx1 = T.makeRegexM $ Pattern "[["::RegexResult R.Regex? rx2 = T.makeRegexM $ Pattern "."::RegexResult R.Regex< isok1 (RegexResult (Left e1)) = traceShow e1 False isok1 _ = True)instance Show (RegexResult R.Regex) where show _ = "bon" tweak Regex with optionsOPQRSTUVWXYZ OPQRSTUVWXYZ TUVWXYZOPSRQOPQRSTUVWXYZ None&)-3457>LN\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&)-3457>LNdimplemented a:  key basedkey may be {any a};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"bcde"text to format e.g. "today is {0}"replacement: [a] or [(a,a)]formatted textfbcdefdebcfbcdefSafe&)-3457>LNmatch offset, length all groupsmatches for one group None&)-3457>LN ghijklmmatched contentnmatched contentopghijklmn lghijkpomnghijklmnopNone&)-3457>LNqa: ,  ByteString, Tb: ,  ByteStringout:[], [[]][ ByteString], [[ ByteString]][3], [[3]]2precompiled Regex may be used as pattern too. see Text.Regex.Do.Pcre.Utf8.Match See also "Text.Regex.Do.Pcre.Ascii.MatchHintto catch regex construction errors , precompile T with V or X sshort version of r: arg without newtypesis borrowed from Text.Regex.PCRE.Wrap  match all match once#"" =~ "tourner gauche"::[PosLen] [(8,2)]  match all@"chilly" =~ "it's chilly inside, chilly outside"::[[ByteString]][["chilly"],["chilly"]] test6"chilly" =~ "it's chilly inside, chilly outside"::BoolTrue  match once""^all" =~ "all the time"::[String] ["all"] qrspatternbodyqrsqrsqrs None&)-3457>LNthint: , , !, , a: , |'Test ("2"::ByteString) =~ "B8E> 2 ;5AC"True ~'Once ("^all"::String) =~ "all the time"["all"] (PosLen' ("8"::String) =~ "1K205B 8 EC65"[(13,2)] tuvwhint & patternbody4type defined by the instance, determined by the hintxyz{|}~tuvwtuvw~}|{zyx tuvwxyz{|}~ Safe&)-3457>LN<see String, ByteString instances for implementation examplessee Text.Regex.Base.RegexLike for  detail  Safe&)-3457>LN4: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" dReplaces 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 safely:1non-existing group idx will not error but return 'adjust for previous replacements lengthsee  source for use exampleDreplace group match while adjusting for previous replacements lengthsee  source for use example  group idx"(group match -> replacement) tweakreplaceable, unadjusted(new val, acc passed to >)new acc None&)-3457>LN internal class & instancesuse  instead  | 9 needs to be specified once with either pat, repl or bodypat: a:  |  ByteString | a( |  (a))( |  (8 a))to catch regex construction errors , precompile  with V or X repl: b:  |  ByteString(4 b)(> b)( |  (4 b))( |  (> b)) body: b:  |  ByteStringb6 b( |  (b))out: |  ByteStringto tweak regex with   or , see Text.Regex.Do.Type.Regexdynamic group replace2custom replacer fn returns replacement value. See replacer::GroupReplacer String' replacer = defaultReplacer 1 tweak1* where tweak1 str1 = case str1 of2 "101" -> "[1 0 1]". "3" -> "[ 3 ]"; otherwise -> trace str1 "?"Greplace (All (Pattern "\\w=(\\d{1,3})")) replacer $ Body "a=101 b=3 12""a=[1 0 1] b=[ 3 ] 12" +static replace for simple (no group) needle for no-regex  ByteString replacement see Text.Regex.Do.Split@replace (Once (Pattern "^a\\s")) (Replacement "A") (Body "a bc")"Abc"dynamic group replaceHreplace (Once (Pattern "\\w=(\\d{1,3})")) replacer $ Body "a=101 b=3 12""a=[1 0 1] b=3 12" hint 6hint 6/replace "^a\\s" (Replacement "A") $ Once "a bc" hint repl/replace "^a\\s" (Once (Replacement "A")) "a bc"hint 8/replace (Once "^a\\s") (Replacement "A") "a bc"full typed arg@replace (Once (Pattern "^a\\s")) (Replacement "A") (Body "a bc") None&)-3457>LN internal class & instancesuse  instead see  Text.Regex.Do.Pcre.Ascii.Replace for implemented typesto catch regex construction errors , precompile T with V or X-in full typed instance every b is wrapped in 1 newtype> is implemented only for  to tweak regex with Comp or Exec, see Text.Regex.Do.Type.Regexnote  Once_Utf8 and All_Utf8 hints *replacer::GroupReplacer (Utf8_ ByteString)+ replacer = defaultReplacer 1 tweak1+ where tweak1 bs1 = toByteString' $? if bs1 == toByteString' "]" then* "0S0". else "?"/runFn1 `shouldBe` toByteString "10000000S0b_0]" where runFn1 == let rx1 = Pattern $ toByteString' "(?<=0)(])"? body1 = Body $ toByteString' "1000000]b_0]"; in replace (All rx1) replacer body1 hint 6replace "?@074=8:" (Replacement "@04>ABL")) (All "M:70<5= - 2A5340 ?@074=8:")hint 6replace "?@074=8:" (Replacement "@04>ABL")* (Once "M:70<5= - 2A5340 ?@074=8:") hint repl$replacer::GroupReplacer (ByteString)#replacer = defaultReplacer 1 tweak1 where tweak1 s1G | s1 == toByteString "[:><0=4K]" = toByteString " - /"B | s1 == toByteString "[AGQB]" = toByteString "5:0"= | s1 == toByteString "[:0:0O 1>;L, ]" = empty= | otherwise = traceShow s1 $ toByteString "?"(let rx1 = toByteString "(\\[[^\\]]+\\])"? body1 = toByteString "[:0:0O 1>;L, ][:><0=4K] : [AGQB]"' in replace rx1 (All replacer) body1" - / : 5:0" hint 8replace (All "?@074=8:") (Replacement "@04>ABL")# "M:70<5= - 2A5340 ?@074=8:"full typed arg+replace (Once $ Pattern $ Utf8_ "?@074=8:")' (Replacement $ Utf8_ "@04>ABL")2 (Body $ Utf8_ "M:70<5= - 2A5340 ?@074=8:")None&)-3457>LNenc: 1a: , , to catch regex construction errors , precompile  with V or Xb: , out:[], [[]][], [[]][3], [[3]]  synonym for . arg without newtypes match all match once4("8"::String) =~ ("1K205B 8 EC65"::String)::[PosLen] [(13,2)]  match allF("well"::String) =~ ("all is well that ends well"::String)::[[String]][["well"],["well"]] 4test. Note that a and b may be different types e.g.  and 1toByteString "2" =~ ("B8E> 2 ;5AC"::String)::Bool True  match onceprecompiled regex as patternZlet rx1 = makeRegexOpt' (Pattern $ toByteString' "]") [] [] -- add options as needed rx2 = Utf8_ <$> rx1L m1 = U.match rx2 (Body $ toByteString' "1000000]b_0]")::[ByteString]- m1 `shouldBe` [toByteString "]"] patternbody None&)-3457>LNhint: , , !, , a: , enc: 15Test (toByteString "2") =~ toByteString "B8E> 2 ;5AC"True 'Once ("^all"::String) =~ "all the time"["all"] (PosLen' ("8"::String) =~ "1K205B 8 EC65"[(13,2)]  hint patternbody4type defined by the instance, determined by the hint           None&)-3457>LN/removes leading and trailing spaces and tabs see  !"#$%&'()*+,-./011223344556789:;<=>?@ABCDDEFFGGHHIIJKLLMNOPQRSTUVWXYZ[\\]^_`abcde f g h i j k l m n o p q r s t u v w x y z {|}~   } ~  jjj|}~}~        regex_12j8bWh5RFMIdfvJBZY5ozText.Regex.Do.Type.ReexportText.Regex.Do.Pcre.Ascii.MatchText.Regex.Do.PadText.Regex.Do.Pcre.OptionText.Regex.Do.Type.MatchHintText.Regex.Do.Type.DoText.Regex.Do.ConvertText.Regex.Do.Type.RegexText.Regex.Do.SplitText.Regex.Do.FormatText.Regex.Do.Pcre.Matchf"Text.Regex.Do.Pcre.Ascii.MatchHintText.Regex.Do.Type.ExtractText.Regex.Do.ReplaceOpen Text.Regex.Do.Pcre.Ascii.ReplaceText.Regex.Do.Pcre.Utf8.ReplaceText.Regex.Do.Pcre.Utf8.Match!Text.Regex.Do.Pcre.Utf8.MatchHintText.Regex.Do.TrimText.Regex.Do.Resultregex_47KXx9dLqeO8MNJeizLKhPText.Regex.Base.RegexLike MatchArrayextractregex_D90DoxwgsTHEvoLrkciZPUText.Regex.PCRE.Wrap CompOption ExecOptionRegexpadpad'ExecBlankENotEmptyPartialCompBlankAnchoredCaselessDotall MultilineUtf8UngreedycompexecHintunhinthintPosLen_PosLen'AllOnceTestswap$fApplicativeAll$fApplicativeOnce $fHintPosLen_ $fHintPosLen' $fHintAll $fHintOnce $fHintTestEnc'val'enc'EncvalencUtf8_PosLen ReplacementBodyPattern ReplaceAccaccpos_adj GroupReplacer$fEnc'Replacementenc$fEnc'GroupReplacerenc $fEncUtf8_$fApplicativeUtf8_$fApplicativeReplacement$fApplicativeBody$fApplicativePattern$fFunctorReplaceAccToArraytoArray toByteString toByteString'toString $fToArray[]$fToArrayArray RegexResultRo_Opt_Rx_ makeRegex makeRegexM makeRegexOpt makeRegexOptM makeRegex' makeRegexOpt' KeepNeedleDropFrontEndreplacebreaksplit ReplaceOne replaceOneFormatformat FormatableMatchfHPmarray_poslen_R_onceall $fMatchfAllb $fMatchfOncebMatchmatch=~ MatchHintF$fMatchHintAllByteString$fMatchHintOnceByteString$fMatchHintPosLen_ByteString$fMatchHintPosLen'ByteString$fMatchHintTestByteString$fMatchHintAll[]$fMatchHintOnce[]$fMatchHintPosLen_[]$fMatchHintPosLen'[]$fMatchHintTest[]Extract'concat'len'prefixsuffix$fExtract'Text $fExtractText$fExtract'Utf8_$fExtractUtf8_$fExtract'ByteString $fExtract'[] ReplaceOpendefaultReplacergetGroup replaceMatchRepl_Replace'ReplaceTrimtrim $fTrimText$fTrim[]$fTrimByteStringpad_RegexSRegexB execBlank execNotEmpty execPartial compBlank compAnchored compCaseless compDotAll compMultilinecompUTF8 compUngreedycompOptexecOptbaseGHC.Basefail makeRegexOptsmakeRegexOptsM$fMonadRegexResult$fApplicativeRegexResult $fRegexRegex $fRegex[]$fRegexByteString $fRegexUtf8_break' breakFrontbreakEndsplit'splitEnd splitFront checkPatternStringbytes_6VWy06pWzJq9evDvK2d4w6Data.ByteString.Internal ByteStringtext_HmqVQnZSpjaC156ABqPhneData.Text.InternalText $fFormata[] $fFormata[]0 CustomerFn foldFn_idx foldFn_map foldr_idxfoldFn$fReplaceOneTextText$fReplaceOneIntText $fReplaceOneByteStringByteString$fReplaceOneIntByteString$fReplaceOne[][]$fReplaceOneInt[]poslen allMatches groupMatchghc-prim GHC.TypesBool $fMatchab[] $fMatchab[]0 $fMatchab[]1 $fMatchabBool $fMatchab[]2ExtractNothing firstGroup adjustPoslen$fReplaceOpen[]GroupReplacer$fReplaceOpenMaybeGroupReplacer$fReplaceOpen[]Replacement$fReplaceOpenMaybeReplacement$fReplace'Allareplb$fReplace'Onceareplb$fReplaceareplAllb$fReplaceareplOnceb$fReplaceaallbb$fReplaceallreplbb$fReplaceallreplBodybreplace'replace_dum_ replace_bs')$fReplace'AllUtf8_ByteStringGroupReplacer$fReplacebreplAllb$fReplacebreplOnceb$fReplaceballbb replace_str replace_bs*$fReplace'OnceUtf8_ByteStringGroupReplacer'$fReplace'AllUtf8_ByteStringReplacement($fReplace'OnceUtf8_ByteStringReplacement$fReplace'AllUtf8_[]Replacement $fReplace'OnceUtf8_[]Replacement$fMatchUtf8_ab[]$fMatchUtf8_ab[]0$fMatchUtf8_ab[]1$fMatchUtf8_abBool$fMatchUtf8_ab[]2mr_$fMatchHintTestUtf8_ByteString$fMatchHintOnceUtf8_[]$fMatchHintPosLen'Utf8_[]$fMatchHintAllUtf8_ByteString$fMatchHintOnceUtf8_ByteString!$fMatchHintPosLen_Utf8_ByteString!$fMatchHintPosLen'Utf8_ByteString$fMatchHintAllUtf8_[]$fMatchHintPosLen_Utf8_[]$fMatchHintTestUtf8_[] Data.Textstrip