Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

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 

Methods

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

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

Ord Regex 

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 

Methods

showsPrec :: Int -> Regex -> ShowS #

show :: Regex -> String #

showList :: [Regex] -> ShowS #

compile

data Option Source #

Instances

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.