Karya, built on 2022-03-21T01:30:44 (patch 89d1651424c35e564138d93424a157ff87457245)
Safe HaskellSafe-Inferred

Util.Regex

Description

More user friendly regex api for PCRE regexes.

Synopsis

Documentation

data Regex #

An abstract pointer to a compiled PCRE Regex structure The structure allocated by the PCRE library will be deallocated automatically by the Haskell storage manager.

Instances

Instances details
Show Regex 
Instance details

Defined in Text.Regex.PCRE.Light.Base

Methods

showsPrec :: Int -> Regex -> ShowS #

show :: Regex -> String #

showList :: [Regex] -> ShowS #

Eq Regex 
Instance details

Defined in Text.Regex.PCRE.Light.Base

Methods

(==) :: Regex -> Regex -> Bool #

(/=) :: Regex -> Regex -> Bool #

Ord Regex 
Instance details

Defined in Text.Regex.PCRE.Light.Base

Methods

compare :: Regex -> Regex -> Ordering #

(<) :: Regex -> Regex -> Bool #

(<=) :: Regex -> Regex -> Bool #

(>) :: Regex -> Regex -> Bool #

(>=) :: Regex -> Regex -> Bool #

max :: Regex -> Regex -> Regex #

min :: Regex -> Regex -> Regex #

compile

data Option Source #

Instances

Instances details
Show Option Source # 
Instance details

Defined in Util.Regex

Eq Option Source # 
Instance details

Defined in Util.Regex

Methods

(==) :: Option -> Option -> Bool #

(/=) :: Option -> Option -> Bool #

Ord Option Source # 
Instance details

Defined in Util.Regex

compileUnsafe :: Stack.HasCallStack => String -> Regex Source #

Will throw a runtime error if the regex has an error!

compileOptionsUnsafe :: Stack.HasCallStack => [Option] -> String -> Regex Source #

Will throw a runtime error if the regex has an error!

matching

groups :: Regex -> Text -> [(Text, [Text])] Source #

Return (complete_match, [group_match]).

groupRanges Source #

Arguments

:: Regex 
-> Text 
-> [((Int, Int), [(Int, Int)])]

(entire, [group])

Half-open ranges of where the regex matches.

substitute

substitute :: Regex -> Text -> Text -> Text Source #

TODO this is not the usual thing where it replaces 1 2 etc., but it replaces the entire match.

substituteGroups Source #

Arguments

:: Regex 
-> (Text -> [Text] -> Text)

(complete_match -> groups -> replacement)

-> Text 
-> Text 

misc

escape :: String -> String Source #

Escape a string so the regex matches it literally.