predictype / predicates/regexps / regexpResult
regexpResult(
pattern,oper,target):boolean
Defined in: predicates/regexps/regexpResult.ts:33
Evaluates a RegExp against a target string and validates the result using the specified operation.
RegExp
The RegExp pattern to apply.
The result operation to perform (e.g. ‘tests’, ‘matches’).
string
The candidate string to validate.
boolean
True if the result operation is valid according to the operator, otherwise false.
If the operation is not recognized.
const pattern = /cat/i;
const targetA = 'My Cat is sleeping';
const targetB = 'dog only';
regexpResult(pattern, 'tests', targetA); // true
regexpResult(pattern, 'not_matches', targetB); // true
Supported Operators: