@abaplint/runtime 2.3.58 → 2.3.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/src/abap_regex.js
CHANGED
|
@@ -11,6 +11,9 @@ class ABAPRegExp {
|
|
|
11
11
|
ret = ret.replace("[[:space:]]", "\\s");
|
|
12
12
|
return ret;
|
|
13
13
|
}
|
|
14
|
+
static escapeRegExp(text) {
|
|
15
|
+
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
exports.ABAPRegExp = ABAPRegExp;
|
|
16
19
|
//# sourceMappingURL=abap_regex.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replace = void 0;
|
|
4
|
+
const abap_regex_1 = require("../abap_regex");
|
|
4
5
|
const offset_length_1 = require("../offset_length");
|
|
5
|
-
|
|
6
|
-
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
7
|
-
}
|
|
6
|
+
const types_1 = require("../types");
|
|
8
7
|
function replace(input) {
|
|
9
8
|
let temp = input.target.get();
|
|
10
9
|
const ignoreCase = input.ignoringCase === true ? "i" : "";
|
|
@@ -17,15 +16,16 @@ function replace(input) {
|
|
|
17
16
|
throw "REPLACE, zero length input";
|
|
18
17
|
}
|
|
19
18
|
found = temp.indexOf(inp) >= 0;
|
|
20
|
-
inp = escapeRegExp(inp);
|
|
19
|
+
inp = abap_regex_1.ABAPRegExp.escapeRegExp(inp);
|
|
21
20
|
search = new RegExp(inp, ignoreCase + allOccurrences);
|
|
22
21
|
}
|
|
23
22
|
else if (input.regex) {
|
|
24
|
-
|
|
23
|
+
const regex = abap_regex_1.ABAPRegExp.convert(input.regex.get());
|
|
24
|
+
if (regex.length === 0 && input.all === true) {
|
|
25
25
|
throw "REPLACE, zero length input";
|
|
26
26
|
}
|
|
27
|
-
found = temp.match(
|
|
28
|
-
search = new RegExp(
|
|
27
|
+
found = temp.match(regex) !== null;
|
|
28
|
+
search = new RegExp(regex, ignoreCase + allOccurrences);
|
|
29
29
|
}
|
|
30
30
|
else if (input.sectionLength && input.sectionOffset) {
|
|
31
31
|
new offset_length_1.OffsetLength(input.target, { length: input.sectionLength, offset: input.sectionOffset }).set(input.with);
|
|
@@ -41,7 +41,12 @@ function replace(input) {
|
|
|
41
41
|
replace = input.with;
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
|
|
44
|
+
if (input.with instanceof types_1.Character) {
|
|
45
|
+
replace = input.with.getTrimEnd();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
replace = input.with.get();
|
|
49
|
+
}
|
|
45
50
|
replace = replace.replace(/\\\$/g, "$");
|
|
46
51
|
replace = replace.replace(/\\\{/g, "{");
|
|
47
52
|
replace = replace.replace(/\\\}/g, "}");
|