Skip to content

Instantly share code, notes, and snippets.

View aMarCruz's full-sized avatar

Alberto Martínez aMarCruz

  • Quits
  • Mexico
View GitHub Profile
@aMarCruz
aMarCruz / sanitizeForRegex.js
Created August 28, 2018 14:30
Escape an string for using with a Regex constructor
function sanitizeForRegex (str) {
return String(str).replace(/(?=[.?*+^$[\]\\(){}|-])/g, '\\')
}