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

    Variable humanToRegexConst

    humanToRegex: (humanText: string, testValue?: string) => TextExtractionResult = parseHumanTextToRegex

    Converts human-readable text descriptions into regular expression patterns. This is a convenient alias for parseHumanTextToRegex that provides the same functionality with natural language processing to understand pattern requirements.

    Type declaration

      • (humanText: string, testValue?: string): TextExtractionResult
      • Parses a human-readable string to generate a regular expression. It first attempts to find complex, compound patterns, then looks for direct keyword matches, and finally falls back to constructing a pattern from individual text components.

        Parameters

        • humanText: string

          The natural language string describing the desired regex.

        • OptionaltestValue: string

          An optional string to test against the generated regex for confidence scoring.

        Returns TextExtractionResult

        A TextExtractionResult object containing the generated pattern, confidence, and other metadata.

    Natural language description of the desired regex pattern. Examples: "email address", "phone number with dashes", "text that starts with A"

    Optional test string to validate the generated pattern against and improve confidence scoring. If provided, the function will test the pattern and adjust confidence based on whether the test passes.

    A TextExtractionResult object containing:

    • success: Boolean indicating if pattern generation succeeded
    • pattern: Generated RegExp object (undefined if failed)
    • confidence: Number between 0-1 indicating pattern reliability
    • description: Human-readable description of the generated pattern
    • suggestions: Array of helpful suggestions for improvement
    // Basic email pattern
    const result = humanToRegex("email address");
    console.log(result.pattern); // /^[^\s@]+@[^\s@]+\.[^\s@]+$/

    // Complex positional pattern
    const startPattern = humanToRegex("starts with 'user_' followed by numbers");

    // With test validation
    const phoneResult = humanToRegex("US phone number", "+1-555-123-4567");
    console.log(phoneResult.confidence); // Higher confidence due to successful test