UNPKG

@abaplint/runtime

Version:
40 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.count = count; const compare_1 = require("../compare"); const types_1 = require("../types"); function count(input) { let found = 0; let val = input.val.get(); if (input.off) { const off = input.off.get(); val = val.substring(off); } if (input.len) { const len = input.len.get(); val = val.substring(0, len); } let reg = ""; if (input.sub) { reg = input.sub.get(); reg = reg.replace(/\*/g, "\\*"); } else if (input.regex) { reg = input.regex.get(); } else if (input.pcre) { reg = input.pcre.get(); } let options = "g"; if (input.case && (0, compare_1.initial)(input.case)) { options += "i"; } if (val !== "") { const res = val.match(new RegExp(reg, options)); if (res) { found = res.length; } } return new types_1.Integer().set(found); } //# sourceMappingURL=count.js.map