API

jamesallardice edited this page Apr 25, 2013 · 1 revision
Clone this wiki locally

Welcome to the Regulate API. All available Regulate methods can be found here.

Regulate().toString()

Converts the current regular expression into a string

Returns

String

Regulate().toRegExp()

Converts the current regular expression into a RegExp object

Returns

RegExp

Regulate().start()

Adds an start-of-string anchor to the current regular expression

Returns

Regulate

Regulate.end()

Adds an end-of-string anchor to the current regular expression

Returns

Regulate

Regulate().string(str)

Adds a simple string to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
str String The string to add undefined Yes

Returns

Regulate

Regulate().anything([linebreaks])

Adds an 'anything' metacharacter to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
linebreaks Boolean If true the added metacharacter will also match line break characters undefined No

Returns

Regulate

Regulate().group(content[, nonCapturing])

Adds a group containing the specified content to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
content String,Regulate The contents of the group undefined Yes
nonCapturing Boolean If true the group will be non-capturing undefined No

Returns

Regulate

Regulate().charIn([negated,] ...char)

Adds a character class to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
negated Boolean If true this method will add a negated character class to the regular expression undefined No
char String,Array Any number of characters or simple ranges to include in the class undefined Yes

Returns

Regulate

Regulate().charNotIn(...char)

Adds a negated character class to the current regular expression

Returns

Regulate

Regulate().repeat(min[, max])

Makes the previous character/group of the current regular expression repeatable

Arguments

Accepts the following arguments

Argument Type Description Default Required
min Number The minimum number of repetitions. Less than 0 signifies infinite repetions (including absence) undefined Yes
max Number The maximum number of repetitions. 0 indicates no upper bound undefined No

Returns

Regulate

Regulate().optional()

Makes the previous character/group of the current regular expression optional

Returns

Regulate

Regulate().followedBy(content[, negated])

Adds a lookahead to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
content String,Regulate The contents of the lookahead undefined Yes
negated Boolean If true this method will create a negative lookahead undefined No

Returns

Regulate

Regulate().notFollowedBy(content)

Adds a negative lookahead to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
content String,Regulate The contents of the negative lookahead undefined Yes

Returns

Regulate

Regulate().wordBoundary([negated])

Adds a word boundary metacharacter to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
negated Boolean If true the metacharacter used will match all non-word-boundaries undefined No

Returns

Regulate

Regulate().or()

Adds an 'or' operator to the current regular expression

Returns

Regulate

Regulate().range(...r)

Adds a construct to match a specific range of letters or numbers to the current regular expression

Arguments

Accepts the following arguments

Argument Type Description Default Required
r Array Any number of arrays containing 2 elements representing the lower and upper bounds of the range undefined Yes

Returns

Regulate