|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
461 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | module.exports = string => {
|
|---|
| 4 | if (typeof string !== 'string') {
|
|---|
| 5 | throw new TypeError('Expected a string');
|
|---|
| 6 | }
|
|---|
| 7 |
|
|---|
| 8 | // Escape characters with special meaning either inside or outside character sets.
|
|---|
| 9 | // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|---|
| 10 | return string
|
|---|
| 11 | .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|---|
| 12 | .replace(/-/g, '\\x2d');
|
|---|
| 13 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.