predictype / predicates/regexps / regexpResultRange
regexpResultRange(
pattern,oper,target,min,max):boolean
Defined in: predicates/regexps/regexpResultRange.ts:54
Counts RegExp matches on a target string and validates whether the count is within a range.
RegExp
The RegExp pattern to apply.
The range operation to perform (e.g. ‘between’, ‘strict_between’).
string
The candidate string to validate.
number
The lower bound of the range.
number
The upper bound of the range.
boolean
True if the range comparison is valid according to the operator, otherwise false.
If the operation is not recognized.
const pattern = /item/g;
const target = 'item,item,item';
const minA = 2;
const maxA = 4;
const minB = 3;
const maxB = 5;
regexpResultRange(pattern, 'between', target, minA, maxA); // true
regexpResultRange(pattern, 'strict_between', target, minB, maxB); // false
Supported Operators: