-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | PCRE wrapper -- -- format, search, replace (String | ByteString) with PCRE regex. -- Utf8-safe @package regex-do @version 2.4 module Text.Regex.Do.Pad -- | pad String with Char to total length of Int -- -- pad on left -- --
--   >>> pad '-' 5 "abc"
--   
-- -- "--abc" pad :: Char -> Int -> String -> String -- | pad on right -- --
--   >>> pad' '-' 5 "abc"
--   
-- -- "abc--" pad' :: Char -> Int -> String -> String -- | reexport common types from Text.Regex.PCRE module Text.Regex.Do.Type.Reexport -- | A compiled regular expression data Regex :: * -- | 0 based array, with 0th index indicating the full match. If the full -- match location is not available, represent as (0,0). type MatchArray = Array Int (MatchOffset, MatchLength) newtype CompOption :: * CompOption :: CInt -> CompOption data ExecOption :: * module Text.Regex.Do.Pcre.Option -- | pcre man pages data Comp -- | compBlank Blank :: Comp -- | compAnchored -- -- the 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"). -- -- This effect can also be achieved by appropriate constructs in the -- pattern itself. Anchored :: Comp -- | compCaseless -- -- letters in the pattern match both upper and lower case letters. -- -- It 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. Caseless :: Comp -- | compDotAll -- -- a dot metacharacter in the pattern matches a character of any value, -- including one that indicates a newline. -- -- However, 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. -- -- This option is equivalent to Perl's /s option, and it can be changed -- within a pattern by a (?s) option setting. -- -- A negative class such as [^a] always matches newline characters, -- independent of the setting of this option. Dotall :: Comp -- | compMultiline -- -- 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. -- -- This 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. Multiline :: Comp -- | compUTF8 -- -- 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. Utf8 :: Comp -- | compUngreedy -- -- This option inverts the "greediness" of the quantifiers so that they -- are not greedy by default, but become greedy if followed by "?". -- -- It can also be set by a (?U) option setting within the pattern. Ungreedy :: Comp data Exec -- | execBlank BlankE :: Exec -- | execNotEmpty -- -- 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 pattern -- -- a?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". NotEmpty :: Exec -- | execPartial -- -- see PCREPARTIAL(3) in pcre man pages Partial :: Exec comp :: [Comp] -> CompOption exec :: [Exec] -> ExecOption instance GHC.Enum.Enum Text.Regex.Do.Pcre.Option.Exec instance GHC.Classes.Ord Text.Regex.Do.Pcre.Option.Exec instance GHC.Classes.Eq Text.Regex.Do.Pcre.Option.Exec instance GHC.Enum.Enum Text.Regex.Do.Pcre.Option.Comp instance GHC.Classes.Ord Text.Regex.Do.Pcre.Option.Comp instance GHC.Classes.Eq Text.Regex.Do.Pcre.Option.Comp module Text.Regex.Do.Type.MatchHint newtype Test a -- | test: does body match pattern? Test :: a -> Test a newtype Once a -- | values Once :: a -> Once a newtype All a -- | values All :: a -> All a newtype PosLen' a -- | once PosLen' :: a -> PosLen' a newtype PosLen_ a -- | all PosLen_ :: a -> PosLen_ a class Hint hint unhint :: Hint hint => hint a -> a instance Text.Regex.Do.Type.MatchHint.Hint Text.Regex.Do.Type.MatchHint.Test instance Text.Regex.Do.Type.MatchHint.Hint Text.Regex.Do.Type.MatchHint.Once instance Text.Regex.Do.Type.MatchHint.Hint Text.Regex.Do.Type.MatchHint.All instance Text.Regex.Do.Type.MatchHint.Hint Text.Regex.Do.Type.MatchHint.PosLen' instance Text.Regex.Do.Type.MatchHint.Hint Text.Regex.Do.Type.MatchHint.PosLen_ module Text.Regex.Do.Type.Do -- | see Text.Regex.Do.Pcre.ReplaceOpen defaultReplacer for -- example implementation newtype GroupReplacer b GroupReplacer :: (MatchArray -> ReplaceAcc b -> ReplaceAcc b) -> GroupReplacer b data ReplaceAcc b ReplaceAcc :: b -> Int -> ReplaceAcc b -- | content with some replacements made [acc] :: ReplaceAcc b -> b -- | position adjustment: group replacement length may differ from replaced -- text length [pos_adj] :: ReplaceAcc b -> Int -- | Needle data Pattern a Pattern :: a -> Pattern a -- | Haystack data Body b Body :: b -> Body b data Replacement r Replacement :: r -> Replacement r -- | Offset, Length type PosLen = (MatchOffset, MatchLength) instance GHC.Base.Functor Text.Regex.Do.Type.Do.Replacement instance GHC.Base.Functor Text.Regex.Do.Type.Do.Body instance GHC.Base.Functor Text.Regex.Do.Type.Do.Pattern module Text.Regex.Do.Convert -- | both Ascii and Utf8 toByteString :: String -> ByteString -- | both Ascii and Utf8 toString :: ByteString -> String class ToArray a toArray :: ToArray a => a -> MatchArray instance Text.Regex.Do.Convert.ToArray Text.Regex.Base.RegexLike.MatchArray instance Text.Regex.Do.Convert.ToArray [Text.Regex.Do.Type.Do.PosLen] module Text.Regex.Do.Type.Regex_ class Regex_ a r_ :: Regex_ a => Pattern a -> Regex ropt_ :: Regex_ a => Pattern a -> [Comp] -> [Exec] -> Regex type Rx_ a b = (Regex_ a, Extract b, RegexLike Regex b) type Opt_ a = RegexMaker Regex CompOption ExecOption a -- | tweak Regex with options makeRegexOpts :: Opt_ a => Pattern a -> [Comp] -> [Exec] -> Regex instance Text.Regex.Do.Type.Regex_.Regex_ Data.ByteString.Internal.ByteString instance Text.Regex.Do.Type.Regex_.Regex_ GHC.Base.String instance Text.Regex.Do.Type.Regex_.Regex_ Text.Regex.PCRE.Wrap.Regex module Text.Regex.Do.Type.Extract -- | see String, ByteString instances for implementation examples -- -- see Text.Regex.Base.RegexLike for Extract detail class Extract a => Extract' a concat' :: Extract' a => [a] -> a len' :: Extract' a => a -> Int prefix :: Extract a => PosLen -> a -> a suffix :: Extract a => PosLen -> a -> a instance Text.Regex.Do.Type.Extract.Extract' GHC.Base.String instance Text.Regex.Do.Type.Extract.Extract' Data.ByteString.Internal.ByteString instance Text.Regex.Base.RegexLike.Extract Data.Text.Internal.Text instance Text.Regex.Do.Type.Extract.Extract' Data.Text.Internal.Text -- | see Data.ByteString.Search package -- -- regex is treated as ordinary String module Text.Regex.Do.Split -- |
--   >>> 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") break :: KeepNeedle -> Pattern ByteString -> Body ByteString -> (ByteString, ByteString) -- |
--   >>> replace (Pattern "\n") (Replacement ",") (Body "a\nbc\nde")
--   
-- -- "a,bc,de" replace :: Pattern ByteString -> Replacement ByteString -> Body ByteString -> ByteString -- |
--   >>> 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"] split :: KeepNeedle -> Pattern ByteString -> Body ByteString -> [ByteString] data KeepNeedle -- | needle between parts disappears Drop :: KeepNeedle -- | needle sticks to front of next part Front :: KeepNeedle -- | needle sticks to end of previous part End :: KeepNeedle module Text.Regex.Do.Format class Format a format :: Format a => String -> a -> String instance Text.Regex.Do.Format.Format [GHC.Base.String] instance Text.Regex.Do.Format.Format [(GHC.Base.String, GHC.Base.String)] -- | see Text.Regex.Base.RegexLike and -- Text.Regex.Do.Pcre.MatchHint module Text.Regex.Do.Pcre.Match -- | match covers all result types -- -- compiler looks up the appropriate function depending on the result -- type -- -- =~ is borrowed from Text.Regex.PCRE.Wrap, is a short -- version of match -- -- See also Text.Regex.Do.Pcre.MatchHint class Match a b out where (=~) p0 b0 = match (Pattern p0) (Body b0) match :: Match a b out => Pattern a -> Body b -> out (=~) :: Match a b out => a -> b -> out -- | extract takes an offset and length and has a default implementation of -- extract (off,len) source = before len (after off source) extract :: Extract source => (Int, Int) -> source -> source -- | tweak Regex with options makeRegexOpts :: Opt_ a => Pattern a -> [Comp] -> [Exec] -> Regex instance Text.Regex.Do.Type.Regex_.Rx_ a b => Text.Regex.Do.Pcre.Match.Match a b [b] instance Text.Regex.Do.Type.Regex_.Rx_ a b => Text.Regex.Do.Pcre.Match.Match a b GHC.Types.Bool instance Text.Regex.Do.Type.Regex_.Rx_ a b => Text.Regex.Do.Pcre.Match.Match a b [[b]] instance Text.Regex.Do.Type.Regex_.Rx_ a b => Text.Regex.Do.Pcre.Match.Match a b [Text.Regex.Do.Type.Do.PosLen] instance Text.Regex.Do.Type.Regex_.Rx_ a b => Text.Regex.Do.Pcre.Match.Match a b [[Text.Regex.Do.Type.Do.PosLen]] -- | this module uses TypeFamilies -- -- this module is similar to Text.Regex.Do.Pcre.Match. The -- differences are: -- -- Text.Regex.Do.Pcre.Match is more flexible: accepts -- Pattern Regex, accepts Pattern and Body of -- different types -- -- Text.Regex.Do.Pcre.Match needs to infer result type -- -- in this module the result type is determined by the hint module Text.Regex.Do.Pcre.MatchHint -- | picks Match instance where Pattern and Body are -- of the same type -- -- Hint and inferrable Pattern or Body type -- determine the instance -- -- handy when working with OverloadedStrings, in other cases -- when compiler needs a hint -- --
--   >>> Test ("в"::ByteString) =~ "тихо в лесу"
--   
-- -- True -- --
--   >>> Once ("^all"::String) =~ "all the time"
--   
-- -- ["all"] -- --
--   >>> PosLen' ("и"::String) =~ "бывает и хуже"
--   
-- -- [(13,2)] class (Hint hint, Match a a (F hint a)) => MatchHint hint a where type family F hint a match h0 = match $ unhint h0 (=~) h0 = (=~) $ unhint h0 match :: MatchHint hint a => hint (Pattern a) -> Body a -> F hint a (=~) :: MatchHint hint a => hint a -> a -> F hint a instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.Test GHC.Base.String instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.PosLen' GHC.Base.String instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.PosLen_ GHC.Base.String instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.Once GHC.Base.String instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.All GHC.Base.String instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.Test Data.ByteString.Internal.ByteString instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.PosLen' Data.ByteString.Internal.ByteString instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.PosLen_ Data.ByteString.Internal.ByteString instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.Once Data.ByteString.Internal.ByteString instance Text.Regex.Do.Pcre.MatchHint.MatchHint Text.Regex.Do.Type.MatchHint.All Data.ByteString.Internal.ByteString -- | extensible and reusable replacement functions -- -- Run replacement with your preferred content types e.g. -- Data.Text, from search results with non-PCRE regex or non-regex -- libs -- -- open an issue or a PR on git to request a new Extract' -- instance -- -- Data.Text instance already works module Text.Regex.Do.Pcre.ReplaceOpen -- | Replacement: -- --
--   >>> replace (Just [(4,3)::PosLen]) (Replacement "4567") (Body "abc 123 def"::Body Text)
--   
-- -- "abc 4567 def" -- -- GroupReplacer : -- --
--   >>> replacer::GroupReplacer Text
--       replacer = defaultReplacer 1 tweak1        --  1: first match in group
--             where tweak1 str1 = case str1 of
--                                   "123" -> "[1-2-3]"
--                                   otherwise -> traceShow str1 "?"
--   
-- --
--   >>> replace (Just ([(4,3),(8,2)]::[PosLen])) replacer (Body "abc 123 def"::Body Text)
--   
-- -- "abc [1-2-3] def" class ReplaceOpen f r replace :: (ReplaceOpen f r, Extract' a, ToArray arr) => f arr -> r a -> Body a -> a -- | Replaces specified (by idx) group match with tweaked value. Works for -- one common simple use case -- -- GroupReplacer can be used with complicated regex -- -- another custom dynamic replacer could e.g. inspect all group matches -- before looking up a replacement. defaultReplacer :: Extract' a => Int -> (a -> a) -> GroupReplacer a -- | get group content safely -- -- see defaultReplacer source for use example getGroup :: Extract a => ReplaceAcc a -> MatchArray -> Int -> Maybe a -- | call from your custom GroupReplacer passed to -- replaceGroup -- -- see defaultReplacer source for use example replaceMatch :: Extract' a => PosLen -> (a, ReplaceAcc a) -> ReplaceAcc a instance Text.Regex.Do.Pcre.ReplaceOpen.ReplaceOpen GHC.Base.Maybe Text.Regex.Do.Type.Do.Replacement instance Text.Regex.Do.Pcre.ReplaceOpen.ReplaceOpen [] Text.Regex.Do.Type.Do.Replacement instance Text.Regex.Do.Pcre.ReplaceOpen.ReplaceOpen GHC.Base.Maybe Text.Regex.Do.Type.Do.GroupReplacer instance Text.Regex.Do.Pcre.ReplaceOpen.ReplaceOpen [] Text.Regex.Do.Type.Do.GroupReplacer module Text.Regex.Do.Pcre.Replace -- |

dynamic group replace

-- -- custom replacer fn returns replacement value. See -- defaultReplacer -- --
--   >>> replacer::GroupReplacer String
--       replacer = defaultReplacer 1 tweak1
--             where tweak1 str1 = case str1 of
--                                   "101" -> "[сто один]"
--                                   "3" -> "[three]"
--                                   otherwise -> trace str1 "?"
--   
-- -- Once vs All options -- --
--   >>> replace (Once[]) (Pattern "\\w=(\\d{1,3})") replacer $ Body "a=101 b=3 12"
--   
-- -- "a=[сто один] b=3 12" -- --
--   >>> replace (All[]) (Pattern "\\w=(\\d{1,3})") replacer $ Body "a=101 b=3 12"
--   
-- -- "a=[сто один] b=[three] 12" -- --

static replace for simple (no group) needle

-- -- for no-regex ByteString replacement see -- Text.Regex.Do.Split -- --
--   >>> replace (Once[Utf8]) (Pattern "менее") (Replacement  "более") $ Body "менее менее"
--   
-- -- "более менее" -- --
--   >>> replace (Once[]) (Pattern "^a\\s") (Replacement "A") $ Body "a bc хол.гор."
--   
-- -- "Abc хол.гор." class Replace hint rx r a replace :: Replace hint rx r a => hint [Comp] -> Pattern rx -> r a -> Body a -> a instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.Once rx Text.Regex.Do.Type.Do.Replacement GHC.Base.String instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.All rx Text.Regex.Do.Type.Do.Replacement GHC.Base.String instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.Once rx Text.Regex.Do.Type.Do.Replacement Data.ByteString.Internal.ByteString instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.All rx Text.Regex.Do.Type.Do.Replacement Data.ByteString.Internal.ByteString instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.Once rx Text.Regex.Do.Type.Do.GroupReplacer Data.ByteString.Internal.ByteString instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.All rx Text.Regex.Do.Type.Do.GroupReplacer Data.ByteString.Internal.ByteString instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.Once rx Text.Regex.Do.Type.Do.GroupReplacer GHC.Base.String instance Text.Regex.Do.Type.Regex_.Regex_ rx => Text.Regex.Do.Pcre.Replace.Replace Text.Regex.Do.Type.MatchHint.All rx Text.Regex.Do.Type.Do.GroupReplacer GHC.Base.String module Text.Regex.Do.Trim -- | removes leading and trailing spaces and tabs class Trim a trim :: Trim a => a -> a instance Text.Regex.Do.Trim.Trim Data.ByteString.Internal.ByteString instance Text.Regex.Do.Trim.Trim GHC.Base.String