Skip to main content Link Search Menu Expand Document (external link)

RegExpString overview

Very simple regular expression string module


Table of contents


Constants

DIGIT_GROUP_SIZE

Size of a group of digits

Signature

export declare const DIGIT_GROUP_SIZE: 3

Constructors

escape

Escapes all regex special characters

Signature

export declare const escape: MTypes.StringTransformer

fromRegExp

Creates a string representing a regular expression from a regular expression

Signature

export declare const fromRegExp: (regExp: RegExp) => string

Instances

CR

A regular expression string representing a carriage return

Signature

export declare const CR: string

LF

A regular expression string representing a line-feed

Signature

export declare const LF: string

anyChar

A regular expression string representing any character

Signature

export declare const anyChar: "."

anyWord

A regular expression string representing a word

Signature

export declare const anyWord: string

anyWordLetter

A regular expression string representing a word letter

Signature

export declare const anyWordLetter: string

anythingButDot

A regular expression string representing anything but a dot

Signature

export declare const anythingButDot: "[^.]"

arrowbase

A regular expression string representing the arrowbase

Signature

export declare const arrowbase: "@"

backslash

A regular expression string representing a backslashString

Signature

export declare const backslash: string

binaryInt

A regular expression string representing an integer in base 2.

Signature

export declare const binaryInt: string

digit

A regular expression string representing a digit

Signature

export declare const digit: string

dollar

A regular expression string representing a dollar sign

Signature

export declare const dollar: string

dot

A regular expression string representing a dot

Signature

export declare const dot: string

email

A regular expression string representing an email - Imported from https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression

Signature

export declare const email: string

emptyCapture

A regular expression string representing an empty capturing group

Signature

export declare const emptyCapture: string

hexaInt

A regular expression string representing an integer in base 16.

Signature

export declare const hexaInt: string

int

A regular expression string representing an integer in base 10 with with at least ‘m’ and at most n digits using thousandsSep as thousands separator. m and n must be strictly positive integers with n greater than or equal to m. n may receive the +Infinity value. If you want no thousands separator, pass an empty string to thousandsSep.

Signature

export declare const int: (n?: number, m?: number, thousandsSep?: string) => string

letter

A regular expression string representing a letter

Signature

export declare const letter: "[A-Za-z]"

lineBreak

A regular expression string representing a linebreak in Windows, Unix and Mac Os

Signature

export declare const lineBreak: string

lowerCaseLetter

A regular expression string representing a lowercase letter

Signature

export declare const lowerCaseLetter: "[a-z]"

lowerCaseLetterOrDigit

A regular expression string representing a lowercase letter

Signature

export declare const lowerCaseLetterOrDigit: "[a-z0-9]"

minus

A regular expression string representing a minus sign

Signature

export declare const minus: "-"

nonZeroDigit

A regular expression string representing a strictly positive digit

Signature

export declare const nonZeroDigit: "[1-9]"

octalInt

A regular expression string representing an integer in base 8.

Signature

export declare const octalInt: string

plus

A regular expression string representing a plus sign

Signature

export declare const plus: string

positiveInt

A regular expression string representing a positive integer in base 10 with at least ‘m’ and at most n digits using thousandsSep as thousands separator. m and n must be strictly positive integers with n greater than or equal to m. n may receive the +Infinity value. If you want no thousands separator, pass an empty string to thousandsSep.

Signature

export declare const positiveInt: (n?: number, m?: number, thousandsSep?: string) => string

semVer

A regular expression string representing a SemVer. Imported from https://semver.org/

Signature

export declare const semVer: string

sign

A regular expression string representing a plus or a minus sign

Signature

export declare const sign: string

slash

A regular expression string representing a slash

Signature

export declare const slash: string

star

A regular expression string representing a star

Signature

export declare const star: string

strictlyPositiveInt

A regular expression string representing a strictly positive integer in base 10 with at least ‘m’ and at most n digits using thousandsSep as thousands separator. m and n must be strictly positive integers with n greater than or equal to m. n may receive the +Infinity value. If you want no thousands separator, pass an empty string to thousandsSep.

Signature

export declare const strictlyPositiveInt: (n?: number, m?: number, thousandsSep?: string) => string

tab

A regular expression string representing a tab

Signature

export declare const tab: string

universalPathSep

A path separator regular expression string to split all possible paths

Signature

export declare const universalPathSep: string

upperCaseLetter

A regular expression string representing an uppercase letter

Signature

export declare const upperCaseLetter: "[A-Z]"

whitespaces

A regular expression string representing several whitespaces

Signature

export declare const whitespaces: string

Utils

atEnd

Returns a new regular expression string where self must be at the end of a line

Signature

export declare const atEnd: MTypes.StringTransformer

atStart

Returns a new regular expression string where self must be at the start of a line

Signature

export declare const atStart: MTypes.StringTransformer

capture

Returns a new regular expression string where self will be captured

Signature

export declare const capture: MTypes.StringTransformer

characterClass

Returns a regular expression string that will match one of the provided characters

Signature

export declare const characterClass: (...args: ReadonlyArray<string>) => string

either

Returns a regular expression string that will match one of the provided regular expression strings

Signature

export declare const either: (...args: ReadonlyArray<string>) => string

makeLine

Returns a new regular expression string where self must fill a whole line

Signature

export declare const makeLine: MTypes.StringTransformer

negativeLookAhead

Returns a new regular expression string where self will be used as negative lookahead

Signature

export declare const negativeLookAhead: MTypes.StringTransformer

oneOrMore

Returns a new regular expression string where self may appear 1 or more times

Signature

export declare const oneOrMore: MTypes.StringTransformer

optional

Returns a new regular expression string where self is optional

Signature

export declare const optional: MTypes.StringTransformer

positiveLookAhead

Returns a new regular expression string where self will be used as ppositive lookahead

Signature

export declare const positiveLookAhead: MTypes.StringTransformer

repeatAtMost

Returns a new regular expression string where self may appear between 0 and high times. high must be an integer. If high is null or negative, the function returns an empry string. If high is +Infinity, the function is an alias to zeroOrMore

Signature

export declare const repeatAtMost: (high: number) => MTypes.StringTransformer

repeatBetween

Returns a new regular expression string where self may appear between low and high times. Both low and high must be integers. If high is null or negative or strictly less than low, the function returns an empry string. high may receive the +Infinity value.

Signature

export declare const repeatBetween: (low: number, high: number) => MTypes.StringTransformer

zeroOrMore

Returns a new regular expression string where self may appear 0 or more times

Signature

export declare const zeroOrMore: (self: string) => string