MCPcopy
hub / github.com/witheve/Eve / unescapeRegexReplace

Function unescapeRegexReplace

src/codemirror.js:13057–13079  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

13055 // Unescape \ and / in the replace part, for PCRE mode.
13056 var unescapes = {'\\/': '/', '\\\\': '\\', '\\n': '\n', '\\r': '\r', '\\t': '\t'};
13057 function unescapeRegexReplace(str) {
13058 var stream = new CodeMirror.StringStream(str);
13059 var output = [];
13060 while (!stream.eol()) {
13061 // Search for \.
13062 while (stream.peek() && stream.peek() != '\\') {
13063 output.push(stream.next());
13064 }
13065 var matched = false;
13066 for (var matcher in unescapes) {
13067 if (stream.match(matcher, true)) {
13068 matched = true;
13069 output.push(unescapes[matcher]);
13070 break;
13071 }
13072 }
13073 if (!matched) {
13074 // Don't change anything
13075 output.push(stream.next());
13076 }
13077 }
13078 return output.join('');
13079 }
13080
13081 /**
13082 * Extract the regular expression from the query and return a Regexp object.

Callers 1

VimFunction · 0.85

Calls 4

eolMethod · 0.95
peekMethod · 0.95
nextMethod · 0.95
matchMethod · 0.95

Tested by

no test coverage detected