verbalexpressions-1.0.0.0: Regular expressions made easy

Safe HaskellNone

Text.Regex.VerbalExpressions

Description

A library to make it easier to work with regular expressions. Based on the (original) Javascript VerbalExpression library by jehna.

Here's some examples, first a http validator:

 let expr =    endOfLine
                . anythingBut " "
                . possibly "www"
                . find "://"
                . possibly "s"
                . find "http"
                . startOfLine
                . searchGlobal
                $ verEx

You can use VerEx's test to find if it matches.

 test "http://www.google.com" expr
 True

The actual expression is the following in regexp:

 ^(?:http)(?:s)?(?:://)(?:www.)?(?:[^ ]*)$

Replacing a string.

 let replaceMe = "Replace bird with a duck"
 let expr2 = find "bird" $ verEx;
 foo = replace replaceMe "duck" expr2

The above can be shortened.

 bar = replace "We have a red house" "blue" . find "red" $ verEx

Basic usage of Verbal Expressions is through a singleton, called verEx, that compiles it to a regexp.

 let expr = (all of your terms) $ verEx 

Documentation

verEx :: VerStructSource

add :: String -> VerStruct -> VerStructSource

startOfLine :: VerStruct -> VerStructSource

startOfLine' :: Bool -> VerStruct -> VerStructSource

endOfLine :: VerStruct -> VerStructSource

endOfLine' :: Bool -> VerStruct -> VerStructSource

find :: String -> VerStruct -> VerStructSource

possibly :: String -> VerStruct -> VerStructSource

anything :: VerStruct -> VerStructSource

anythingBut :: String -> VerStruct -> VerStructSource

something :: VerStruct -> VerStructSource

somethingBut :: String -> VerStruct -> VerStructSource

replace :: String -> String -> VerStruct -> StringSource

lineBreak :: VerStruct -> VerStructSource

br :: VerStruct -> VerStructSource

tab :: VerStruct -> VerStructSource

word :: VerStruct -> VerStructSource

anyOf :: String -> VerStruct -> VerStructSource

range :: [String] -> VerStruct -> VerStructSource

withAnyCase :: VerStruct -> VerStructSource

withAnyCase' :: Bool -> VerStruct -> VerStructSource

searchOneLine :: VerStruct -> VerStructSource

searchOneLine' :: Bool -> VerStruct -> VerStructSource

searchGlobal :: VerStruct -> VerStructSource

searchGlobal' :: Bool -> VerStruct -> VerStructSource

multiple :: String -> VerStruct -> VerStructSource

alt :: String -> VerStruct -> VerStructSource

test :: String -> VerStruct -> BoolSource