headroom-0.3.1.0: License Header Manager

Copyright(c) 2019-2020 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.Data.Regex

Contents

Description

Extends functionalify provided by Text.Regex.PCRE.Light and Text.Regex.PCRE.Heavy that more suits the needs of this application.

Synopsis

Data Types

newtype Regex Source #

Represents compiled regex, encapsulates the actual implementation.

Constructors

Regex Regex 
Instances
Eq Regex Source # 
Instance details

Defined in Headroom.Data.Regex

Methods

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

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

Show Regex Source # 
Instance details

Defined in Headroom.Data.Regex

Methods

showsPrec :: Int -> Regex -> ShowS #

show :: Regex -> String #

showList :: [Regex] -> ShowS #

FromJSON Regex Source # 
Instance details

Defined in Headroom.Data.Regex

data RegexError Source #

Exception specific to the Headroom.Data.Regex module.

Constructors

CompilationFailed !Text !Text

given input cannot be compiled as regex

Regex Functions

compile Source #

Arguments

:: MonadThrow m 
=> Text

regex to compile

-> m Regex

compiled regex

Compiles given regex in runtime. If possible, prefer the re quasi quotation version that does the same at compile time.

match Source #

Arguments

:: Regex

a PCRE regular expression value produced by compile

-> Text

the subject text to match against

-> Maybe [Text]

the result value

Same as match, but works with Text and uses no additional options.

re :: QuasiQuoter Source #

A QuasiQuoter for regular expressions that does a compile time check.

replace Source #

Arguments

:: Regex

regex to match what to replace

-> (Text -> [Text] -> Text)

replacement function (as fullMatch -> [groups] -> result)

-> Text

text to replace in

-> Text

resulting text

Replaces all occurences of given regex.

scan Source #

Arguments

:: Regex

regex to search for

-> Text

input text

-> [(Text, [Text])]

found occurences (as [(fullMatch, [groups])])

Searches the text for all occurences of given regex.

Unsafe Functions

compileUnsafe Source #

Arguments

:: Text

regex to compile

-> Regex

compiled regex or runtime exception

Compiles the given text into regex in runtime. Note that if the regex cannot be compiled, it will throw runtime error. Do not use this function unless you know what you're doing.