Copyright | (c) 2019-2020 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Extends functionalify provided by Text.Regex.PCRE.Light and Text.Regex.PCRE.Heavy that more suits the needs of this application.
Synopsis
- newtype Regex = Regex Regex
- data RegexError = CompilationFailed Text Text
- compile :: MonadThrow m => Text -> m Regex
- match :: Regex -> Text -> Maybe [Text]
- re :: QuasiQuoter
- replace :: Regex -> (Text -> [Text] -> Text) -> Text -> Text
- scan :: Regex -> Text -> [(Text, [Text])]
- compileUnsafe :: Text -> Regex
Data Types
Represents compiled regex, encapsulates the actual implementation.
data RegexError Source #
Exception specific to the Headroom.Data.Regex module.
CompilationFailed Text Text | given input cannot be compiled as regex |
Instances
Show RegexError Source # | |
Defined in Headroom.Data.Regex showsPrec :: Int -> RegexError -> ShowS # show :: RegexError -> String # showList :: [RegexError] -> ShowS # | |
Exception RegexError Source # | |
Defined in Headroom.Data.Regex toException :: RegexError -> SomeException # fromException :: SomeException -> Maybe RegexError # displayException :: RegexError -> String # |
Regex Functions
:: 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.
re :: QuasiQuoter Source #
A QuasiQuoter for regular expressions that does a compile time check.
:: Regex | regex to match what to replace |
-> (Text -> [Text] -> Text) | replacement function (as |
-> Text | text to replace in |
-> Text | resulting text |
Replaces all occurences of given regex.
:: Regex | regex to search for |
-> Text | input text |
-> [(Text, [Text])] | found occurences (as |
Searches the text for all occurences of given regex.
Unsafe Functions
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.