@nodescript/stdlib
Version:
Standard Node Definitions
23 lines (22 loc) • 556 B
JavaScript
export const module = {
version: '1.2.4',
moduleName: 'RegExp / Test',
description: 'Tests if a string matches specified regular expression.',
keywords: ['match'],
params: {
string: {
schema: { type: 'string' },
},
regexp: {
schema: { type: 'any' },
},
},
result: {
schema: { type: 'boolean' },
}
};
export const compute = (params, ctx) => {
const { string } = params;
const regexp = ctx.lib.toRegExp(params.regexp);
return regexp.test(string);
};