String.prototype.match()

0
4K

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
Социальные проблемы
Атлетка А: Скандал в американской гимнастике. Athlete A. (2020)
История одного из самых крупных скандалов в профессиональном спорте в США. Врач сборной США по...
By Nikolai Pokryshkin 2022-10-18 14:10:06 0 19K
Recreation
The Art of Shopping as Recreation: Exploring the Joy Beyond Purchases
Shopping has transcended its utilitarian roots to become a leisure activity in its own right. No...
By Dacey Rankins 2024-06-03 18:24:16 0 10K
Jewelry
Why are people so attracted to jewelry?
Have you ever wondered why you like gold and precious stones so much? Why do you want to buy...
By FWhoop Xelqua 2023-01-04 16:41:17 0 10K
Office Products
Office Tools
Choosing office suppliesIs it time to stock up on office stationery? Not sure where to start?...
By FWhoop Xelqua 2023-03-25 16:24:05 0 16K
Социальные проблемы
Удалить историю. Delete History. (2020)
Жизнь троих обитателей городка подчинена новейшим технологиям и опутана социальными сетями....
By Nikolai Pokryshkin 2022-10-15 21:52:58 1 16K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov