predictype / predicates/strings/stringPattern / stringPattern
stringPattern(
source
,oper
,pattern
):boolean
Defined in: predicates/strings/stringPattern.ts:26
Evaluates a string against a pattern operation (matches or not matches a RegExp) using the specified operation.
string
The string to test.
The pattern operation to perform (e.g. ‘matches’, ‘not_matches’).
RegExp
The RegExp to test against.
boolean
True if the operation matches, false otherwise.
If the operation is not recognized.
const str = 'foobar';
const pattern1 = /^foo/;
const pattern2 = /baz/;
stringPattern(str, 'matches', pattern1); // true
stringPattern(str, 'not_matches', pattern2); // true
Supported Operators: