If needle is a regular expression, then JavaScript's RegExp test() is used. Note that this is only used if needle
is a RegExp object, not if it is a string that looks like a regular expression—a string will be matched with the
string rules.
If needle is a string, it is matched against haystack using the following tests:
* always matches.
word* will needle strings that begin with word, i.e. wording.
*word will needle strings that end with word, i.e. unword.
*or* will needle nothing; use a regular expression instead.
Strings without a *, or that don't begin or end with * will be matched only if they are strictly equal to haystack.
Test if
needlecan be matched againsthaystack.If
needleis a regular expression, then JavaScript's RegExptest()is used. Note that this is only used ifneedleis a RegExp object, not if it is a string that looks like a regular expression—a string will be matched with the string rules.If
needleis a string, it is matched againsthaystackusing the following tests:*always matches.word*will needle strings that begin withword, i.e.wording.*wordwill needle strings that end withword, i.e.unword.*or*will needle nothing; use a regular expression instead.*, or that don't begin or end with*will be matched only if they are strictly equal tohaystack.