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

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: string

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

base10Number

Returns a regular expression string representing a number in base 10 using thousandSeparator as thousand separator, fractionalSeparator as fractional separator and eNotationChars as possible characters for scientific notation.

  • thousandSeparator: Usually a string made of at most one character but not mandatory. Should be different from fractionalSeparator. Will not throw otherwise but unexpected results might occur. Use ‘’ for no thousand separator.
  • fractionalSeparator: usually a one-character string but not mandatory (e.g. ‘.’). Should not be an empty string and be different from thousandSeparator. Will not throw otherwise but unexpected results might occur.
  • eNotationChars: array of possible chracters that can be used to represent an exponent (e.g. value: [‘E’, ‘e’]).
  • fillChar: usually a one-character string but not mandatory (e.g. ‘ ‘). If not an empty string, zero or more fillChars are tolerated between the sign and the number (or at the start of the number if it is unsigned). Beware if you use a number as fillChar (e.g. you use ‘0’ as fillChar and try to parse ‘0000’)

Signature

export declare const base10Number: ({
  thousandSeparator,
  fractionalSeparator,
  eNotationChars,
  fillChar
}: {
  readonly thousandSeparator: string
  readonly fractionalSeparator: string
  readonly eNotationChars: ReadonlyArray<string>
  readonly fillChar: string
}) => 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

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

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

space

A regular expression string representing a space

Signature

export declare const space: string

spaces

A regular expression string representing zero or more spaces

Signature

export declare const spaces: string

star

A regular expression string representing a star

Signature

export declare const star: 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

unsignedBase10Int

Returns a regular expression string representing an unsigned integer in base 10 using thousandSeparator as thousand separator. Pass an empty string for no thousand separator.

Signature

export declare const unsignedBase10Int: (thousandSeparator: string) => string

unsignedNonNullBase10Int

Returns a regular expression string representing an unsigned non-null integer in base 10 using thousandSeparator as thousand separator. Pass an empty string for no thousand separator.

Signature

export declare const unsignedNonNullBase10Int: (thousandSeparator: string) => string

upperCaseLetter

A regular expression string representing an uppercase letter

Signature

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

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

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

notInRange

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

Signature

export declare const notInRange: (args: MTypes.OverOne<string>) => string

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

optionalCapture

Returns a new regular expression string where self is made optional and captured

Signature

export declare const optionalCapture: MTypes.StringTransformer

positiveLookAhead

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

Signature

export declare const positiveLookAhead: MTypes.StringTransformer

range

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

Signature

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

repeatBetween

Returns a new regular expression string where self may appear between low and high times. low must be a positive integer inferior or equal to high. high must be a strictly positive integer that may receive the +Infinity value.

Signature

export declare const repeatBetween: (low: number, high: number) => MTypes.OneArgFunction<string>

zeroOrMore

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

Signature

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