Options
All
  • Public
  • Public/Protected
  • All
Menu

Module regex

RegEx Basic Functions

RegEx Find Functions

RegEx From Functions

RegEx Is Functions

RegEx Make Functions

RegEx Match Functions

RegEx Basic Functions

regexBasicStripSpaces

  • regexBasicStripSpaces(text: string): string
  • name

    regexBasicStripSpaces

    description

    Replace multiple white-spaces in string.

    summary

    import { regexBasicStripSpaces } from "@corefunc/corefunc/regex/basic/strip-spaces";

    since

    0.3.27

    example

    regexBasicStripSpaces(" too\n many \tspaces "); āžœ "too many spaces"

    Parameters

    • text: string

      String with white-spaces.

    Returns string

    String with replaced white-spaces.

regexReplace

  • regexReplace(haystack: string, needle: string, replaceWith: RegExp | RegExp[] | string | string[]): string
  • name

    regexReplace

    description

    Replace all occurrences of the search string with the replacement string

    example

    regexReplace('target', 'search', 'replace');

    example

    regexReplace('target', ['search 1', 'search 2'], 'replace');

    example

    regexReplace('target', ['search 1', 'search 2'], ['replace 1', 'replace 2']);

    Parameters

    • haystack: string
    • needle: string
    • replaceWith: RegExp | RegExp[] | string | string[]

    Returns string

RegEx Find Functions

regexFindNumbers

  • regexFindNumbers(text: string): number[]
  • description

    Executes a search for a match between a regular expression and a specified string.

    Parameters

    • text: string

    Returns number[]

RegEx From Functions

regexFromVerbose

  • regexFromVerbose(input: TemplateStringsArray): RegExp
  • name

    regexFromVerbose

    example

    new RegExp( regexFromVerbose (?<!\\) \s // Ignore whitespace, but not // when escaped with backslash. | [/][/] .* // Single-line comment. | [/][*] [\s\S]* [*][/] // Multi-line comment. // Note: /[\s\S]/ is same as /./s // with dot-all flag (s)., "g", ); const regExp = regexFromVerbose (0 | [1-9] [0-9]*) // Integer part with no leading zeroes \. // Dot [0-9]* // Fractional part (optional) ([eE] [+-]? [0-9]+)? // Exponent part (optional);

    Parameters

    • input: TemplateStringsArray

    Returns RegExp

RegEx Is Functions

regexIsDateIso

  • regexIsDateIso(stringWithDate: string): boolean
  • name

    regexIsDateIso

    description

    Checks if a string is an ISO-compliant date.

    summary

    import { regexIsDateIso } from '@corefunc/corefunc/regex/is/date-iso';

    example

    regexIsDateIso("2134-12-30T12:34:56.789Z") āžœ true

    example

    regexIsDateIso("2134-12-30T12:34:56Z") āžœ true

    example

    regexIsDateIso("2134-12-30T12:34Z") āžœ true

    since

    0.3.22

    Parameters

    • stringWithDate: string

      String to check for ISO date.

    Returns boolean

regexIsMultiline

  • regexIsMultiline(text: string): boolean
  • name

    regexIsMultiline

    description

    Checks if a line has line breaks

    example

    regexIsMultiline("šŸ“•šŸ“—\nšŸ“˜šŸ“–") āžœ true

    since

    0.0.98

    Parameters

    • text: string

      Text to check for line breaks

    Returns boolean

RegEx Make Functions

regexMakeEscaped

  • regexMakeEscaped(text: string): string
  • name

    regexMakeEscaped

    description

    Escapes RegExp special characters

    since

    0.1.12

    Parameters

    • text: string

    Returns string

    Escaped text

RegEx Match Functions

regexMatch

  • regexMatch(string: string, pattern: RegExp | [string, string] | string, onFail?: boolean): boolean
  • name

    regexMatch

    description

    Executes a search for a match between a regular expression and a specified string.

    Parameters

    • string: string
    • pattern: RegExp | [string, string] | string
    • onFail: boolean = false

    Returns boolean

Generated using TypeDoc