Module: strings

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:

  • 'i' - Case-insensitive matching
  • 'g' - Global matching (finds all matches, not just the first one)
  • 'm' - Multiline mode
  • 's' - Dotall mode, where the dot . matches any character including newlines
  • 'u' - Enables full Unicode support, allowing correct handling of surrogate pairs
  • 'y' - Sticky mode for searching at a particular position in the text
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