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]().

Buscar
Categorías
Read More
Marketing and Advertising
What Can Telemarketing Be Used For (and When Is It Effective)? Understanding Applications, Strategy, and Impact
Introduction Telemarketing has long been a cornerstone of direct marketing, offering businesses...
By Dacey Rankins 2025-11-05 14:51:21 0 2K
Arts, Culture and Entertainment
The Forty-Year-Old Version. (2020)
Radha is a down-on-her-luck NY playwright, who is desperate for a breakthrough before 40....
By Leonard Pokrovski 2022-10-03 20:45:31 0 30K
Financial Services
Interpreting the aggregate demand/aggregate supply model
Key points The aggregate demand/aggregate supply model is a model that...
By Mark Lorenzo 2023-03-08 17:45:51 0 19K
Programming
Tips to Avoid Ratelimits
Ratelimits can happen when you send a request too many times in a certain amount of time. To...
By Jesse Thomas 2023-02-16 22:02:39 0 11K
Business
Conflict Resolution Techniques [FAQs Guide]
Conflict is an inevitable part of life—whether at work, school, home, or in social...
By Dacey Rankins 2025-06-09 15:13:52 0 10K

BigMoney.VIP Powered by Hosting Pokrov