Utility class for handling regular expressions.

Methods

Methods

  • Escapes RegExp special characters in a string.

    Parameters

    • str: string

      The string to escape.

    • Optionalreplace: Record<string, string>

      A map of custom replacement characters.

    Returns string

    The escaped string.

    import {Regex} from 'nodejs-shared';

    Regex.escape('//example.com/?lang=english');// //example\\.com/\\?lang=english