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

Pesquisar
Categorias
Leia Mais
Business
What is a Solopreneur?
In today’s entrepreneurial landscape, the term solopreneur has become increasingly popular....
Por Dacey Rankins 2025-02-11 16:19:46 0 6K
Business
How Can I Manage Cash Flow Effectively?
Effective cash flow management is vital for the success of any business, regardless of its size....
Por Dacey Rankins 2025-03-05 21:01:35 0 8K
Телевидение
Музыка Мода ТВ Прямой эфир.
Музыка Мода ТВ - российский музыкально-развлекательный телеканал, который создан 29 июня 2021...
Por Nikolai Pokryshkin 2022-11-25 17:46:26 0 24K
Социальные проблемы
Огни большого города. City Lights. (1931)
Маленький Бродяга встречает красивую слепую девушку, торгующую цветами на улице, которая по...
Por Nikolai Pokryshkin 2022-12-10 18:04:28 0 23K
Социальные проблемы
Молочные зубы. Babyteeth. (2020)
Когда Милла встречает Мозеса, кажется, что у них ничего общего: она – робкий подросток с...
Por Nikolai Pokryshkin 2022-10-19 17:24:25 0 28K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov