main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
226 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
---|
| 4 |
|
---|
| 5 | module.exports = function (str) {
|
---|
| 6 | if (typeof str !== 'string') {
|
---|
| 7 | throw new TypeError('Expected a string');
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | return str.replace(matchOperatorsRe, '\\$&');
|
---|
| 11 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.