Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions VerbalExpressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ class VerbalExpression extends RegExp {

// Regular expression to match meta characters
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/regexp
const toEscape = /([\].|*?+(){}^$\\:=[])/g;
const toEscape = /[|\\{}()[\]^$+*?.]/g;

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch
const lastMatch = '$&';

// Escape meta characters
return value.replace(toEscape, `\\${lastMatch}`);
return value
.replace(toEscape, `\\${lastMatch}`)
.replace(/-/g, '\\x2d');
}

/**
Expand Down
Loading