Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone

Util.Regex

Contents

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
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 #

Show Regex 
Instance details

Defined in Text.Regex.PCRE.Light.Base

Methods

showsPrec :: Int -> Regex -> ShowS #

show :: Regex -> String #

showList :: [Regex] -> ShowS #

compile

data Option Source #

Instances
Eq Option # 
Instance details

Defined in Util.Regex

Methods

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

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

Ord Option # 
Instance details

Defined in Util.Regex

Show Option # 
Instance details

Defined in Util.Regex

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

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

compileOptionsUnsafe :: CallStack.Stack => [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.