UNPKG

@abaplint/runtime

Version:
26 lines 754 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.match = match; const string_1 = require("../types/string"); function match(input) { const val = typeof input.val === "string" ? input.val : input.val.get(); const regexInput = input.pcre || input.regex; if (regexInput === undefined) { throw "match() requires either regex or pcre parameter"; } let reg = ""; if (typeof regexInput === "string") { reg = regexInput; } else { reg = regexInput.get(); } const r = new RegExp(reg); const res = val.match(r); let ret = ""; if (res && res[0]) { ret = res[0]; } return new string_1.String().set(ret); } //# sourceMappingURL=match.js.map