UNPKG

@abaplint/runtime

Version:
50 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.substring_after = substring_after; const abap_regex_1 = require("../abap_regex"); const types_1 = require("../types"); const string_1 = require("../types/string"); function substring_after(input) { let source; if (input.val instanceof types_1.FieldSymbol) { const pointer = input.val.getPointer(); if (pointer === undefined) { throw new Error("GETWA_NOT_ASSIGNED"); } source = pointer; } else { source = input.val; } let val = typeof source === "string" ? source : source.get(); if (source instanceof types_1.Character) { val = source.getTrimEnd(); } let reg = ""; if (typeof input.regex === "string") { reg = input.regex; } else if (typeof input.pcre === "string") { reg = input.pcre; } else if (input?.regex) { reg = input.regex.get(); } else if (input?.pcre) { reg = input.pcre.get(); } else if (typeof input.sub === "string") { reg = abap_regex_1.ABAPRegExp.escapeRegExp(input.sub); } else if (input?.sub) { reg = abap_regex_1.ABAPRegExp.escapeRegExp(input.sub.get()); } const r = new RegExp(reg + "(.*)"); const res = val.match(r); let ret = ""; if (res && res[1]) { ret = res[1]; } return new string_1.String().set(ret); } //# sourceMappingURL=substring_after.js.map