String.prototype.match()

0
10K

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
Business
What role does technology play in business forecasting?
In today’s rapidly evolving business landscape, forecasting has become an indispensable...
By Dacey Rankins 2025-01-13 14:41:10 0 9K
Financial Services
Law of supply
Key points The law of supply states that a higher price leads to a higher...
By Mark Lorenzo 2023-06-28 19:25:37 0 11K
People
50 artists that left a mark in history
50 artists and their works that have left a mark on history and people's hearts...
By FWhoop Xelqua 2023-07-09 18:10:51 0 29K
Business
What legal requirements are there for fundraising?
Fundraising is a crucial activity for nonprofits, individuals, and organizations looking to raise...
By Dacey Rankins 2025-03-26 16:23:13 0 8K
Environment
The 10 most environmentally friendly countries
The site for expats InterNations interviewed about 15 thousand people who left their home...
By FWhoop Xelqua 2022-12-24 15:35:08 0 19K

BigMoney.VIP Powered by Hosting Pokrov