This module contains routines for strings manipulation
- Source:
Methods
(static) isTextMatch(text, pattern, isRegExpopt, flagsopt) → {boolean}
This is a function that checks if a text string matches a specified pattern,
which can be provided either as a plain string or a regular expression
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
text |
string | Text string for pattern matching | |
pattern |
string | Pattern for matching | |
isRegExp |
string |
<optional> |
Flag indicating that the pattern is a regular expression |
flags |
string |
<optional> |
String with a set of flags for matching text
against a regular expression Flags for regular expressions:
|
- Source:
Returns:
True if the pattern matches. Else - false
- Type
- boolean
Example
let
text = 'test',
pattern = 'Te.*',
flags = 'i',
result;
result = isTextMatch(text, pattern, true, flags);
console.log(result); // true