@syntropiq/py-regex
Version:
Python-compatible regular expressions for TypeScript/JavaScript, mirroring Python's re/regex API.
9 lines • 386 B
JavaScript
/**
* Escape special regex characters in a string to match Python's re.escape() behavior
* This includes escaping spaces, which is crucial for Python regex compatibility
*/
export function escapeRegex(str) {
// Include space in the character class to match Python's re.escape() behavior
return str.replace(/[.*+?^${}()|[\]\\ ]/g, '\\$&');
}
//# sourceMappingURL=escape.js.map