String.prototype.match()

0
6K

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
Radio
The History of Radio: From Waves to Communication Revolution
  Early Beginnings: Theoretical Foundations The history of radio is a fascinating journey...
By Dacey Rankins 2024-10-05 13:29:37 0 17K
Телевидение
Телеканал Доктор Градус. Прямая трансляция.
Телеканал «Доктор Градус» целиком посвящен нетрадиционной медицине. При просмотре...
By Nikolai Pokryshkin 2022-11-18 12:54:04 0 16K
Business
Are Contributions to Crowdfunding Campaigns Tax-Deductible?
Crowdfunding has become a popular way for individuals and organizations to raise money for a wide...
By Dacey Rankins 2025-03-28 14:35:19 0 108
Financial Services
How changes in the cost of living are measured
Key points The Consumer Price Index, or CPI is a measure of...
By Mark Lorenzo 2023-06-09 20:21:34 0 7K
Спорт
Семь самураев. Seven Samurai. (1954)
Япония, XVI век. В стране полыхает гражданская война, повсюду орудуют банды разбойников и...
By Nikolai Pokryshkin 2022-11-15 17:46:10 0 21K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov