String.prototype.match()

0
11K

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

Buscar
Categorías
Read More
Business
How Did They Handle Failure or Setbacks?
No leader rises to prominence without encountering obstacles. In fact, the way a leader handles...
By Dacey Rankins 2025-06-27 16:39:25 0 4K
Ужасы
Психо. Psycho. (1960)
Мэрион Крэйн недовольна романом с разведенным мужчиной, который уделяет ей внимание только...
By Nikolai Pokryshkin 2022-11-24 20:52:18 0 28K
Programming
Python OverflowError
Raised when the result of an arithmetic operation is too large to be represented. This cannot...
By Jesse Thomas 2023-05-04 21:15:23 0 11K
Жизненные вопросы
Поймать последнюю волну. Caught by a Wave. (2021)
Невероятно драматическая история любви, которая в свою очередь поведает о двух подростках,...
By Nikolai Pokryshkin 2022-09-17 09:21:53 0 31K
Occupational Health and Safety
Occupational Health and Safety
Labor protection and safety at the enterprise include a set of measures aimed at ensuring the...
By FWhoop Xelqua 2023-02-10 18:11:24 0 18K

BigMoney.VIP Powered by Hosting Pokrov