String.prototype.match()

0
11χλμ.

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
B2C: how the relationship between business and buyer works
Features of B2C salesA business that is aimed at an ordinary buyer has its own characteristics....
από Dacey Rankins 2024-09-02 19:00:28 0 12χλμ.
Middle East
Why there is a lot of oil in the Middle East, geologists can answer
Why there is a lot of oil in the Middle East, geologists can answerThe Middle East is a region...
από FWhoop Xelqua 2023-04-02 19:18:10 0 34χλμ.
Жизненные вопросы
Из огня да в полымя. Wildfire. (2021)
История двух сестер, выросших на разбитой ирландской границе. Когда одна из них, объявленная...
από Nikolai Pokryshkin 2022-09-08 22:31:45 1 32χλμ.
Спорт
Малышка на миллион. Million Dollar Baby. (2004)
Тренеру по боксу Фрэнку Данну так и не удалось воспитать чемпиона. Он владеет спортивным залом в...
από Nikolai Pokryshkin 2023-03-16 13:50:53 0 30χλμ.
Financial Services
Indexing and its limitations
Key points A payment is said to be indexed if it is automatically...
από Mark Lorenzo 2023-03-24 19:47:37 0 13χλμ.

BigMoney.VIP Powered by Hosting Pokrov