String.prototype.match()

0
12KB

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
Costumes
The most unusual costumes
The show of national costumes at the 71st beauty contest "Miss Universe" in New Orleans caused a...
Por FWhoop Xelqua 2023-01-22 14:30:50 0 24KB
Internet
How to use neural networks to write a script for TikTok, Reels and Shorts
In 2023, neural networks continue to be one of the most actively developing areas. In recent...
Por FWhoop Xelqua 2023-06-12 20:21:19 0 36KB
Economics
What causes high prices?
What Causes High Prices? Walk into a grocery store after a central bank has spent a decade...
Por Leonard Pokrovski 2026-05-09 04:33:01 0 4KB
Visual Arts
Visual Arts
Pictorial art or pictorial arts (from "from" and Art.-Slav. "image"; praslav. ob- + razъ —...
Por FWhoop Xelqua 2023-02-18 13:32:13 0 19KB
Productivity
What certifications matter most?
What Certifications Matter Most? Certifications sit in an awkward space between signal and...
Por Michael Pokrovski 2026-05-31 17:17:04 0 3KB

BigMoney.VIP Powered by Hosting Pokrov