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

Site içinde arama yapın
Kategoriler
Read More
Economics
What Is Late-Stage Capitalism?
What Is Late-Stage Capitalism? “Late-stage capitalism” is a phrase you often see...
By Leonard Pokrovski 2026-02-12 21:53:00 0 6K
Business
Growing Your Business: Strategies for Scaling and Success
Growing a business is an exciting yet challenging process that requires strategic planning,...
By Dacey Rankins 2024-12-16 14:09:11 0 63K
Television
Omega Gospel Live TV. South African Republic.
OMEGA Gospel TV Network is a Christian-based broadcast platform that continuously airs a unique...
By Nikolai Pokryshkin 2022-11-29 18:14:45 0 37K
Decision Making and Problem Solving
Memory improvement for seniors
The mind is not a warehouse, and it is certainly not a hard drive. We operate under the...
By Michael Pokrovski 2026-07-18 00:02:21 0 2K
Productivity
How do I create a minimalist workspace?
How Do I Create a Minimalist Workspace? A minimalist workspace is not simply a “clean...
By Michael Pokrovski 2026-04-18 06:17:56 0 15K

BigMoney.VIP Powered by Hosting Pokrov