predictype / predicates/regexps / regexpPattern
regexpPattern(
pattern,oper,target):boolean
Defined in: predicates/regexps/regexpPattern.ts:29
Checks the pattern string of a RegExp using the specified operation.
RegExp
The RegExp pattern to check.
The pattern operation to perform (e.g. ‘equals’, ‘includes’).
string
The string to compare against the RegExp pattern source.
boolean
True if the pattern check is valid according to the operator, otherwise false.
If the operation is not recognized.
const pattern = /^user_[a-z]+$/;
const targetA = '^user_';
const targetB = 'admin';
regexpPattern(pattern, 'starts_with', targetA); // true
regexpPattern(pattern, 'excludes', targetB); // true
Supported Operators: