forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtst_replace.js
More file actions
44 lines (38 loc) · 1.15 KB
/
tst_replace.js
File metadata and controls
44 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function reg(){
const nonIdPattern = 'a-z';
const basePattern = /[<nonId>]/.source; // $ SPURIOUS:Alert
const finalPattern = basePattern.replace(/<nonId>/g, nonIdPattern);
console.log(finalPattern);
const regex2 = new RegExp(finalPattern);
}
function reg1(){
const nonIdPattern = 'a-z';
const reg = /[<nonId>]/; // $ SPURIOUS:Alert
const basePattern = reg.source;
const finalPattern = basePattern.replace(/<nonId>/g, nonIdPattern);
console.log(finalPattern);
const regex2 = new RegExp(finalPattern);
}
function replacer(reg1, reg2){
const basePattern = reg1.source;
const finalPattern = basePattern.replace(/<nonId>/g, reg2);
return new RegExp(finalPattern);
}
function reg2(){
const nonIdPattern = 'a-z';
const reg = /[<nonId>]/; // $ SPURIOUS:Alert
replacer(reg, nonIdPattern);
}
function replacer3(str, reg2){
const finalPattern = str.replace(/<nonId>/g, reg2);
return new RegExp(finalPattern);
}
function replacer2(reg1, reg2){
const basePattern = reg1.source;
return replacer3(basePattern, reg2);
}
function reg3(){
const nonIdPattern = 'a-z';
const reg = /[<nonId>]/; // $ SPURIOUS:Alert
replacer2(reg, nonIdPattern);
}