INNER CODE UNIT · JavaScript

escapeStringRegexp

ergonode/frontend · cypress/models/index.js:11

export const escapeStringRegexp = (string) => {
    if (typeof string !== 'string') {
        throw new TypeError('Expected a string');
    }

    return string
        .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
        .replace(/-/g, '\\x2d');
};

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…