String.prototype.match()

0
6Кб

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

Поиск
Категории
Больше
Business
How Do I Come Up with a Viable Startup Idea?
Starting a new business can be an exciting yet daunting endeavor. One of the first and most...
От Dacey Rankins 2025-03-24 15:17:00 0 867
Television
ABC Live TV Action Weather 24/7. Tampa Bay, Florida, USA.
ABC Action Weather 24/7. Live Stream. ABC Action News brings you weather coverage from the Tampa...
От Nikolai Pokryshkin 2022-10-30 19:56:11 0 32Кб
Sport
Kill Bill: Vol. 1. (2003)
After awakening from a four-year coma, a former assassin wreaks vengeance on the team of...
От Leonard Pokrovski 2023-02-24 17:06:46 0 13Кб
Retail Trade
Retail
Retail trade is the business activity of selling goods or providing services directly to end...
От Dacey Rankins 2024-03-18 17:20:11 0 18Кб
Искусство, культура и развлечения
Мое сердце разрывается. My Heart Goes Boom!. (2020)
Мюзикл, основанный на хитах популярной итальянской певицы Рафаэллы Карра. Мария с детства мечтала...
От Nikolai Pokryshkin 2022-09-27 17:23:39 0 21Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov