@abaplint/runtime
Version:
Transpiler - Runtime
36 lines • 980 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.matches = matches;
const types_1 = require("../types");
function matches(input) {
if (input.pcre === undefined && input.regex === undefined) {
throw "matches(), todo";
}
const val = typeof input.val === "string" ? input.val : input.val.get();
let reg = "";
if (input.regex) {
if (typeof input.regex === "string") {
reg = input.regex;
}
else {
reg = input.regex.get();
}
}
else if (input.pcre) {
if (typeof input.pcre === "string") {
reg = input.pcre;
}
else {
reg = input.pcre.get();
}
}
const r = new RegExp("^" + reg + "$");
const res = val.match(r);
if (res !== null) {
return new types_1.Character().set("X");
}
else {
return new types_1.Character().set(" ");
}
}
//# sourceMappingURL=matches.js.map