RGex Builder Platform - v1.2.0
    Preparing search index...

    Class RGex

    Main RGex class with fluent API

    Index

    Constructors

    Methods

    • Converts a human-readable text description into a regex pattern.

      Parameters

      • humanText: string

        The natural language description of the pattern.

      • OptionaltestValue: string

        An optional string to test the generated pattern against.

      Returns TextExtractionResult

      A result object containing the pattern and analysis.

    • Converts a human-readable text description into a set of validation rules.

      Parameters

      • humanText: string

        The natural language description of the validation rules.

      • OptionaltestValue: string

        An optional string to test the generated rules against.

      Returns ValidationExtractionResult

      A result object containing the validation rules.

    • Gets pattern suggestions based on a human-readable text input.

      Parameters

      • text: string

        The input text to get suggestions for.

      Returns string[]

      An array of suggested pattern keywords.

    • Creates a new RGex instance from a human-readable text description.

      Parameters

      • humanText: string

        The natural language description of the pattern.

      • OptionaltestValue: string

        An optional string to test the generated pattern against.

      Returns RGex

      A new RGex instance.

    • Replaces the current pattern with one generated from a human-readable text description.

      Parameters

      • humanText: string

        The natural language description of the pattern.

      • OptionaltestValue: string

        An optional string to test the generated pattern against.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a literal string to the pattern, escaping special regex characters.

      Parameters

      • text: string

        The literal string to append.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a raw (unescaped) regex pattern string.

      Parameters

      • pattern: string

        The raw pattern string to append.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a character class to the pattern.

      Parameters

      • chars: string

        The characters to include in the class.

      • negate: boolean = false

        If true, creates a negated character class.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a whitespace character class (\s).

      Returns RGex

      The current RGex instance for chaining.

    • Adds a start-of-string anchor (^) to the beginning of the pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Adds an end-of-string anchor ($) to the end of the pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends an OR operator (|) followed by another pattern.

      Parameters

      • pattern: string

        The alternative pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a quantifier to the preceding element.

      Parameters

      • min: number

        The minimum number of repetitions.

      • Optionalmax: number

        The maximum number of repetitions. Use Infinity for no upper limit.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a zero-or-more quantifier (*).

      Returns RGex

      The current RGex instance for chaining.

    • Wraps a pattern in a capturing group.

      Parameters

      • pattern: string

        The pattern to group.

      Returns RGex

      The current RGex instance for chaining.

    • Wraps a pattern in a non-capturing group.

      Parameters

      • pattern: string

        The pattern to group.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a lookahead assertion.

      Parameters

      • pattern: string

        The pattern for the lookahead.

      • negative: boolean = false

        If true, creates a negative lookahead.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a lookbehind assertion.

      Parameters

      • pattern: string

        The pattern for the lookbehind.

      • negative: boolean = false

        If true, creates a negative lookbehind.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built email validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built phone number validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built date (YYYY-MM-DD) validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built time (HH:MM or HH:MM:SS) validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built number (integer or decimal) validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built UUID validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built IPv4 validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Appends a pre-built hex color code validation pattern.

      Returns RGex

      The current RGex instance for chaining.

    • Enables or disables the global (g) flag.

      Parameters

      • enabled: boolean = true

        If true, the flag is enabled.

      Returns RGex

      The current RGex instance for chaining.

    • Enables or disables the ignore case (i) flag.

      Parameters

      • enabled: boolean = true

        If true, the flag is enabled.

      Returns RGex

      The current RGex instance for chaining.

    • Enables or disables the multiline (m) flag.

      Parameters

      • enabled: boolean = true

        If true, the flag is enabled.

      Returns RGex

      The current RGex instance for chaining.

    • Enables or disables the dotAll (s) flag.

      Parameters

      • enabled: boolean = true

        If true, the flag is enabled.

      Returns RGex

      The current RGex instance for chaining.

    • Enables or disables the unicode (u) flag.

      Parameters

      • enabled: boolean = true

        If true, the flag is enabled.

      Returns RGex

      The current RGex instance for chaining.

    • Enables or disables the sticky (y) flag.

      Parameters

      • enabled: boolean = true

        If true, the flag is enabled.

      Returns RGex

      The current RGex instance for chaining.

    • Tests if the generated regex pattern matches a given string.

      Parameters

      • input: string

        The string to test.

      Returns boolean

      True if the pattern matches, otherwise false.

    • Executes the regex pattern against a string and returns the match details.

      Parameters

      • input: string

        The string to execute the pattern on.

      Returns null | RegExpExecArray

      A RegExpExecArray if a match is found, otherwise null.

    • Finds all matches of the pattern in a string.

      Parameters

      • input: string

        The string to search.

      Returns null | string[]

      An array of matches, or null if no matches are found.

    • Replaces occurrences of the pattern in a string.

      Parameters

      • input: string

        The string to perform the replacement on.

      • replacement: string | ((match: string, ...args: any[]) => string)

        The string or function to use for replacement.

      Returns string

      The modified string.

    • Splits a string using the regex pattern as a delimiter.

      Parameters

      • input: string

        The string to split.

      Returns string[]

      An array of strings.

    • Checks if the current regex pattern is syntactically valid.

      Returns boolean

      True if the pattern is valid, otherwise false.

    • Gets the raw regex pattern string.

      Returns string

      The pattern string.

    • Gets the flags string (e.g., "gi").

      Returns string

      The flags string.

    • Builds and returns the final RegExp object.

      Returns RegExp

      A RegExp object.

    • Creates a new RGex instance with the same pattern and options.

      Returns RGex

      A new RGex instance.

    • Resets the pattern and options to their initial state.

      Returns RGex

      The current RGex instance for chaining.

    • Returns the string representation of the regex pattern.

      Returns string

      The pattern string.

    • Returns a JSON representation of the RGex instance.

      Returns { pattern: string; flags: string; valid: boolean }

      An object containing the pattern, flags, and validity.

    • Creates a new RGex instance from a JSON object.

      Parameters

      • json: { pattern: string; flags?: string }

        An object containing the pattern and optional flags.

      Returns RGex

      A new RGex instance.

      Will throw an error if the pattern in the JSON is invalid.

    • Escapes special characters in a string for use in a regex.

      Parameters

      • text: string

        The string to escape.

      Returns string

      The escaped string.

    • Validates if a given string is a valid regex pattern.

      Parameters

      • pattern: string

        The pattern to validate.

      Returns boolean

      True if the pattern is valid, otherwise false.

    • Normalizes text by converting to lowercase and removing extra whitespace.

      Parameters

      • text: string

        The text to normalize.

      Returns string

      The normalized text.

    Properties

    pattern: string = ''
    options: RegexBuilderOptions = {}
    h2r: (humanText: string, testValue?: string) => TextExtractionResult = RGex.toRegex

    Alias for RGex.toRegex.

    Type declaration

      • (humanText: string, testValue?: string): TextExtractionResult
      • Converts a human-readable text description into a regex pattern.

        Parameters

        • humanText: string

          The natural language description of the pattern.

        • OptionaltestValue: string

          An optional string to test the generated pattern against.

        Returns TextExtractionResult

        A result object containing the pattern and analysis.

    h2v: (humanText: string, testValue?: string) => ValidationExtractionResult = RGex.toValidate

    Alias for RGex.toValidate.

    Type declaration

      • (humanText: string, testValue?: string): ValidationExtractionResult
      • Converts a human-readable text description into a set of validation rules.

        Parameters

        • humanText: string

          The natural language description of the validation rules.

        • OptionaltestValue: string

          An optional string to test the generated rules against.

        Returns ValidationExtractionResult

        A result object containing the validation rules.

    human: (humanText: string, testValue?: string) => RGex = RGex.humanText

    Alias for RGex.humanText.

    Type declaration

      • (humanText: string, testValue?: string): RGex
      • Creates a new RGex instance from a human-readable text description.

        Parameters

        • humanText: string

          The natural language description of the pattern.

        • OptionaltestValue: string

          An optional string to test the generated pattern against.

        Returns RGex

        A new RGex instance.

    suggest: (text: string) => string[] = RGex.getSuggestions

    Alias for RGex.getSuggestions.

    Type declaration

      • (text: string): string[]
      • Gets pattern suggestions based on a human-readable text input.

        Parameters

        • text: string

          The input text to get suggestions for.

        Returns string[]

        An array of suggested pattern keywords.