Module

Data.String.VerEx

Package
purescript-verbal-expressions
Repository
VerbalExpressions/purescript-verbal-expressions

This module contains a free monad implementation of Verbal Expressions. for PureScript.

#VerExF Source

data VerExF a

The grammar for Verbal Expressions, used internally.

#VerExM Source

type VerExM = Free VerExF

The free monad over the VerExF type constructor.

#VerEx Source

type VerEx = VerExM Unit

A monadic action that constructs a Verbal Expression.

#VerExReplace Source

type VerExReplace = VerExM String

A monadic action that constructs a Verbal Expression and returns a replacement string.

#VerExMatch Source

type VerExMatch = VerExM (Array CaptureGroup)

A monadic action that constructs a Verbal Expression and returns an array of capture group indices.

#CaptureGroup Source

newtype CaptureGroup

#startOfLine' Source

startOfLine' :: Boolean -> VerExM Unit

Set whether or not the expression has to start at the beginning of the line. Default: false.

#startOfLine Source

startOfLine :: VerExM Unit

Mark the expression to start at the beginning of the line.

#endOfLine' Source

endOfLine' :: Boolean -> VerExM Unit

Set whether or not the expression has to end at the end of the line. Default: false.

#endOfLine Source

endOfLine :: VerExM Unit

Mark the expression to end at the end of the line.

#find Source

find :: String -> VerExM Unit

Add a string to the expression.

#possibly Source

possibly :: forall a. VerExM a -> VerExM a

Add a sub-expression which might appear zero or one times.

#anything Source

anything :: VerExM Unit

Match any charcter, any number of times.

#anythingBut Source

anythingBut :: String -> VerExM Unit

Match anything but the specified characters.

#something Source

something :: VerExM Unit

Match any charcter, at least one time.

#anyOf Source

anyOf :: String -> VerExM Unit

Any of the given characters.

#some Source

some :: VerEx -> VerExM Unit

Repeat the inner expression one or more times.

#many Source

many :: VerEx -> VerExM Unit

Repeat the inner expression zero or more times.

#exactly Source

exactly :: Int -> VerEx -> VerExM Unit

Repeat the inner expression exactly the given number of times.

#lineBreak Source

lineBreak :: VerExM Unit

Add universal line break expression.

#tab Source

tab :: VerExM Unit

Add expression to match a tab character.

#word Source

word :: VerExM Unit

Adds an expression to match a word.

#digit Source

digit :: VerExM Unit

Adds an expression to match a single digit.

#upper Source

upper :: VerExM Unit

Adds an expression to match a single uppercase character (ASCII range). Note that this will match uppercase and lowercase characters if withAnyCase is used.

#lower Source

lower :: VerExM Unit

Adds an expression to match a single lowercase character (ASCII range). Note that this will match uppercase and lowercase characters if withAnyCase is used.

#whitespace Source

whitespace :: VerExM Unit

Any whitespace character

#withAnyCase Source

withAnyCase :: VerExM Unit

Enable case-insensitive matching

#capture Source

capture :: VerEx -> VerExM CaptureGroup

Add a new capture group which matches the given VerEx. Returns the index of the capture group.

#findAgain Source

findAgain :: CaptureGroup -> VerExM Unit

Match a previous capture group again (back reference).

#replaceWith Source

replaceWith :: String -> VerExReplace

Replace the matched string with the given replacement.

#insert Source

insert :: CaptureGroup -> String

Add the contents of a given capture group in the replacement string.

#toRegex Source

toRegex :: forall a. VerExM a -> Regex

Convert a Verbal Expression to a Regular Expression.

#test Source

test :: forall a. VerExM a -> String -> Boolean

Check whether a given String matches the Verbal Expression.

#replace Source

replace :: VerExReplace -> String -> String

Replace occurences of the VerEx with the String that is returned by the monadic action.

#match Source

match :: VerExMatch -> String -> Maybe (Array (Maybe String))

Match the VerEx against the string argument and (maybe) return an Array of possible results from the specified capture groups.