String.prototype.match()

0
8K

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

Cerca
Categorie
Leggi tutto
Television
WTNH News 8 Newscasts Live TV. New Haven, Connecticut, USA.
WTNH, channel 8, is an ABC-affiliated television station located in New Haven, Connecticut, USA....
By Nikolai Pokryshkin 2022-11-08 19:34:30 0 23K
Business
What Is Competitive Advantage in Business Strategy?
In today’s fast-paced and competitive business world, the ability to outperform competitors...
By Dacey Rankins 2024-12-25 18:28:06 0 9K
Business
What is Business Strategy? A Clear Definition and Examples
Business strategy is a crucial concept that defines how a company will achieve its long-term...
By Dacey Rankins 2024-12-23 16:01:27 0 6K
Mental Health
Psychosis: Classification
ClassificationThe word was also used to distinguish a condition considered a disorder of the...
By Kelsey Rodriguez 2023-05-19 18:06:19 0 8K
Science Fiction and Fantasy
Batman Begins. (2005)
After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from...
By Leonard Pokrovski 2023-02-03 16:09:37 0 18K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov