String.prototype.match()

0
11K

A regular expression object, or any object that has a Symbol.match method.

If regexp is not a RegExp object and does not have a Symbol.match method, it is implicitly converted to a RegExp by using new RegExp(regexp).

If you don't give any parameter and use the match() method directly, you will get an Array with an empty string: [""], because this is equivalent to match(/(?:)/).

Return value

An Array whose contents depend on the presence or absence of the global (g) flag, or null if no matches are found.

  • If the g flag is used, all results matching the complete regular expression will be returned, but capturing groups are not included.
  • If the g flag is not used, only the first complete match and its related capturing groups are returned. In this case, match() will return the same result as RegExp.prototype.exec() (an array with some extra properties).

Description

The implementation of String.prototype.match itself is very simple — it simply calls the Symbol.match method of the argument with the string as the first parameter. The actual implementation comes from RegExp.prototype[@@match]().

For more information about the semantics of match() when a regex is passed, see RegExp.prototype[@@match]().

Search
Categories
Read More
Television
FOX 32, Live TV. Chicago USA
FOX 32 is Chicago's source for news, weather, sports and entertainment. Our dedicated news team...
By Nikolai Pokryshkin 2022-09-14 08:52:28 0 41K
Business
Usability and Effectiveness: Do Your Products Truly Work for Your Customers?
When evaluating a product or service, one of the most important questions a customer can answer...
By Dacey Rankins 2025-07-25 14:02:28 0 5K
Business
What Ethical Considerations Are Involved in Influencer Marketing?
Influencer marketing has become one of the most prominent strategies in digital marketing today....
By Dacey Rankins 2025-02-28 15:57:27 0 9K
Financial Services
Beyond GDP: other ways to measure the economy
Key points Gross national product, or GNP, includes what is produced...
By Mark Lorenzo 2023-03-03 19:43:30 0 22K
Marketing and Advertising
What Is Affiliate Marketing?
Affiliate marketing is one of the most popular and effective digital marketing strategies. It...
By Dacey Rankins 2025-09-17 10:54:16 0 6K

BigMoney.VIP Powered by Hosting Pokrov