Skip to content

Commit

Permalink
feat: $test[]: test strings for regex matches
Browse files Browse the repository at this point in the history
  • Loading branch information
Faf4a committed Mar 23, 2024
1 parent d4677a1 commit 83134bb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/functions/util/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = async (d) => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

let [text, pattern, flag = "g"] = data.inside.splits;

if (!["g", "i", "m", "s", "u", "y"].includes(flag)) return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Invalid Flag Provided In")

const regex = new RegExp(pattern, flag);

data.result = regex.test(text);

return {
code: d.util.setCode(data)
}
}

0 comments on commit 83134bb

Please sign in to comment.