@abaplint/runtime 2.13.26 → 2.13.27

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.
@@ -1,5 +1,6 @@
1
1
  import { ICharacter } from "../types/_character";
2
2
  export declare function match(input: {
3
3
  val: ICharacter | string;
4
- regex: ICharacter | string;
4
+ regex?: ICharacter | string;
5
+ pcre?: ICharacter | string;
5
6
  }): ICharacter;
@@ -4,12 +4,16 @@ exports.match = match;
4
4
  const string_1 = require("../types/string");
5
5
  function match(input) {
6
6
  const val = typeof input.val === "string" ? input.val : input.val.get();
7
+ const regexInput = input.pcre || input.regex;
8
+ if (regexInput === undefined) {
9
+ throw "match() requires either regex or pcre parameter";
10
+ }
7
11
  let reg = "";
8
- if (typeof input.regex === "string") {
9
- reg = input.regex;
12
+ if (typeof regexInput === "string") {
13
+ reg = regexInput;
10
14
  }
11
15
  else {
12
- reg = input.regex.get();
16
+ reg = regexInput.get();
13
17
  }
14
18
  const r = new RegExp(reg);
15
19
  const res = val.match(r);
@@ -6,6 +6,7 @@ export interface IReplaceInput {
6
6
  sub?: string | ICharacter;
7
7
  with?: string | ICharacter;
8
8
  regex?: string | ICharacter;
9
+ pcre?: string | ICharacter;
9
10
  off?: INumeric;
10
11
  len?: INumeric;
11
12
  occ?: INumeric;
@@ -38,11 +38,12 @@ function replace(input) {
38
38
  if (sub !== undefined) {
39
39
  sub = abap_regex_1.ABAPRegExp.escapeRegExp(sub);
40
40
  }
41
- if (typeof input.regex === "string") {
42
- sub = new RegExp(abap_regex_1.ABAPRegExp.convert(input.regex), "g");
41
+ const regexInput = input.pcre || input.regex;
42
+ if (typeof regexInput === "string") {
43
+ sub = new RegExp(abap_regex_1.ABAPRegExp.convert(regexInput), "g");
43
44
  }
44
- else if (input.regex) {
45
- sub = new RegExp(abap_regex_1.ABAPRegExp.convert(input.regex.get()), "g");
45
+ else if (regexInput) {
46
+ sub = new RegExp(abap_regex_1.ABAPRegExp.convert(regexInput.get()), "g");
46
47
  }
47
48
  if (input.off && input.len && typeof input.val === "string") {
48
49
  const offset = input.off.get();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.26",
3
+ "version": "2.13.27",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",