String.prototype.match()

0
12K

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

Pesquisar
Categorias
Leia Mais
Business
How Can Social Media Help Business Growth?
In the modern digital economy, businesses of all sizes—from local startups to global...
Por Dacey Rankins 2025-09-05 15:36:49 0 25K
Decision Making and Problem Solving
How can designers use lateral thinking?
The Architecture of the Intellectual Pivot The mind is a pattern-making machine. It is...
Por Michael Pokrovski 2026-07-09 16:18:44 0 724
Economics
Why do consumers have more choices in free markets?
Why Do Consumers Have More Choices in Free Markets? Walk into a grocery store today and stand in...
Por Leonard Pokrovski 2026-06-03 20:28:38 0 1K
Economics
How is economic growth calculated?
How Is Economic Growth Calculated? The Number That Governs Nations A curious feature of modern...
Por Leonard Pokrovski 2026-06-14 18:02:46 0 3K
Economics
What are the features of industrial relations?
What Are the Features of Industrial Relations? Industrial relations (IR) refer to the...
Por Leonard Pokrovski 2026-07-10 00:06:49 0 3K

BigMoney.VIP Powered by Hosting Pokrov