2016-04-28 20:50:03 -04:00
|
|
|
import {RegExpWrapper, StringWrapper} from '../src/facade/lang';
|
|
|
|
|
|
|
|
var _RE_SPECIAL_CHARS =
|
2016-05-02 01:50:37 -04:00
|
|
|
['-', '[', ']', '/', '{', '}', '\\', '(', ')', '*', '+', '?', '.', '^', '$', '|'];
|
2016-04-28 20:50:03 -04:00
|
|
|
var _ESCAPE_RE = RegExpWrapper.create(`[\\${_RE_SPECIAL_CHARS.join('\\')}]`);
|
|
|
|
export function containsRegexp(input: string): RegExp {
|
2016-06-08 19:38:52 -04:00
|
|
|
return RegExpWrapper.create(StringWrapper.replaceAllMapped(
|
|
|
|
input, _ESCAPE_RE, (match: any /** TODO #9100 */) => `\\${match[0]}`));
|
2016-04-28 20:50:03 -04:00
|
|
|
}
|