search
Determines if there is a match between the regular expression and some subsequence in the target character sequence.
const str = "this subject has a submarine as a subsequence";
regex.search("\\b(sub)([^ ]*)", str); //true
regex.search("\\b(su b)([^ ]*)", str); //false
Syntax
search(pattern, expression)
Returns
A boolean indicating whether a match was found.