String.prototype.match()

0
8Кб

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

Поиск
Категории
Больше
Anomalies and Alternative Science
10% of the crew survived: how the Philadelphia experiment actually ended
The Philadelphia Experiment is a classified US Navy experiment staged on October 28, 1943 with...
От FWhoop Xelqua 2023-02-04 19:48:10 0 23Кб
Business
How Can I Finance My Business Without External Funding?
Financing a business without external funding is a viable option for many entrepreneurs who...
От Dacey Rankins 2025-03-31 15:41:06 0 6Кб
Business
How Does the Build-Measure-Learn Feedback Loop Work?
The Build-Measure-Learn feedback loop is a core principle of the Lean Startup methodology,...
От Dacey Rankins 2025-03-07 13:52:36 0 8Кб
Жизненные вопросы
Токийская повесть. Tokyo Story. (1953)
Пожилая супружеская пара едет из провинции в Токио навестить детей: сына, ставшего доктором, и...
От Nikolai Pokryshkin 2023-04-13 10:36:07 0 23Кб
Men's Health
Men's Health: Why Do Some Men Find It Difficult To Talk About Their Problems And Illnesses?
One of the main reasons why men find it difficult to discuss their health and problems is...
От Dacey Rankins 2024-04-17 14:07:45 0 15Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov