Initializes a new instance of the RGex class.
The initial regex pattern string.
The initial regex options.
Static
createCreates a new RGex instance, providing a static entry point to the fluent API.
The initial regex pattern.
The regex options.
A new RGex instance.
Static
toConverts a human-readable text description into a regex pattern.
The natural language description of the pattern.
Optional
testValue: stringAn optional string to test the generated pattern against.
A result object containing the pattern and analysis.
Static
toConverts a human-readable text description into a set of validation rules.
The natural language description of the validation rules.
Optional
testValue: stringAn optional string to test the generated rules against.
A result object containing the validation rules.
Static
getGets pattern suggestions based on a human-readable text input.
The input text to get suggestions for.
An array of suggested pattern keywords.
Static
humanCreates a new RGex instance from a human-readable text description.
The natural language description of the pattern.
Optional
testValue: stringAn optional string to test the generated pattern against.
A new RGex instance.
Replaces the current pattern with one generated from a human-readable text description.
The natural language description of the pattern.
Optional
testValue: stringAn optional string to test the generated pattern against.
The current RGex instance for chaining.
Appends a literal string to the pattern, escaping special regex characters.
The literal string to append.
The current RGex instance for chaining.
Appends a raw (unescaped) regex pattern string.
The raw pattern string to append.
The current RGex instance for chaining.
Appends a character class to the pattern.
The characters to include in the class.
If true, creates a negated character class.
The current RGex instance for chaining.
Adds a start-of-string anchor (^) to the beginning of the pattern.
The current RGex instance for chaining.
Adds an end-of-string anchor ($) to the end of the pattern.
The current RGex instance for chaining.
Appends an OR operator (|) followed by another pattern.
The alternative pattern.
The current RGex instance for chaining.
Appends a quantifier to the preceding element.
The minimum number of repetitions.
Optional
max: numberThe maximum number of repetitions. Use Infinity for no upper limit.
The current RGex instance for chaining.
Wraps a pattern in a capturing group.
The pattern to group.
The current RGex instance for chaining.
Wraps a pattern in a non-capturing group.
The pattern to group.
The current RGex instance for chaining.
Appends a lookahead assertion.
The pattern for the lookahead.
If true, creates a negative lookahead.
The current RGex instance for chaining.
Appends a lookbehind assertion.
The pattern for the lookbehind.
If true, creates a negative lookbehind.
The current RGex instance for chaining.
Appends a pre-built phone number validation pattern.
The current RGex instance for chaining.
Appends a pre-built date (YYYY-MM-DD) validation pattern.
The current RGex instance for chaining.
Appends a pre-built time (HH:MM or HH:MM:SS) validation pattern.
The current RGex instance for chaining.
Appends a pre-built number (integer or decimal) validation pattern.
The current RGex instance for chaining.
Appends a pre-built hex color code validation pattern.
The current RGex instance for chaining.
Enables or disables the global (g) flag.
If true, the flag is enabled.
The current RGex instance for chaining.
Enables or disables the ignore case (i) flag.
If true, the flag is enabled.
The current RGex instance for chaining.
Enables or disables the multiline (m) flag.
If true, the flag is enabled.
The current RGex instance for chaining.
Enables or disables the dotAll (s) flag.
If true, the flag is enabled.
The current RGex instance for chaining.
Enables or disables the unicode (u) flag.
If true, the flag is enabled.
The current RGex instance for chaining.
Enables or disables the sticky (y) flag.
If true, the flag is enabled.
The current RGex instance for chaining.
Performs advanced password validation using the current pattern as the password to test.
The password validation criteria.
A result object with detailed analysis of the password's strength.
Tests if the generated regex pattern matches a given string.
The string to test.
True if the pattern matches, otherwise false.
Executes the regex pattern against a string and returns the match details.
The string to execute the pattern on.
A RegExpExecArray
if a match is found, otherwise null.
Finds all matches of the pattern in a string.
The string to search.
An array of matches, or null if no matches are found.
Replaces occurrences of the pattern in a string.
The string to perform the replacement on.
The string or function to use for replacement.
The modified string.
Splits a string using the regex pattern as a delimiter.
The string to split.
An array of strings.
Checks if the current regex pattern is syntactically valid.
True if the pattern is valid, otherwise false.
Gets the raw regex pattern string.
The pattern string.
Gets the flags string (e.g., "gi").
The flags string.
Builds and returns the final RegExp
object.
A RegExp
object.
Resets the pattern and options to their initial state.
The current RGex instance for chaining.
Returns the string representation of the regex pattern.
The pattern string.
Returns a JSON representation of the RGex instance.
An object containing the pattern, flags, and validity.
Static
fromCreates a new RGex instance from a JSON object.
An object containing the pattern and optional flags.
A new RGex instance.
Static
escapeEscapes special characters in a string for use in a regex.
The string to escape.
The escaped string.
Static
validateValidates if a given string is a valid regex pattern.
The pattern to validate.
True if the pattern is valid, otherwise false.
Static
normalizeNormalizes text by converting to lowercase and removing extra whitespace.
The text to normalize.
The normalized text.
Private
patternPrivate
optionsStatic
h2rAlias for RGex.toRegex
.
Converts a human-readable text description into a regex pattern.
The natural language description of the pattern.
Optional
testValue: stringAn optional string to test the generated pattern against.
A result object containing the pattern and analysis.
Static
h2vAlias for RGex.toValidate
.
Converts a human-readable text description into a set of validation rules.
The natural language description of the validation rules.
Optional
testValue: stringAn optional string to test the generated rules against.
A result object containing the validation rules.
Static
humanAlias for RGex.humanText
.
Creates a new RGex instance from a human-readable text description.
The natural language description of the pattern.
Optional
testValue: stringAn optional string to test the generated pattern against.
A new RGex instance.
Static
suggestAlias for RGex.getSuggestions
.
Gets pattern suggestions based on a human-readable text input.
The input text to get suggestions for.
An array of suggested pattern keywords.
Main RGex class with fluent API