String.prototype.match()

0
11KB

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

Pesquisar
Categorias
Leia mais
Life Issues
Aladdin (1992)
A kind-hearted street urchin and a power-hungry Grand Vizier vie for a magic lamp that has the...
Por Leonard Pokrovski 2023-07-01 19:45:10 0 33KB
Science Fiction and Fantasy
Spider-Man: No Way Home. (2021)
With Spider-Man's identity now revealed, Peter asks Doctor Strange for help. When a spell goes...
Por Leonard Pokrovski 2023-02-26 16:46:05 0 21KB
Activism
The Power of Activism: Driving Change in Society
Activism is the practice of taking action to bring about social or political change. It...
Por Dacey Rankins 2024-10-14 18:30:40 0 17KB
Business
Is Lean Startup Applicable Only to Tech Companies?
The Lean Startup methodology, popularized by Eric Ries, is often associated with technology...
Por Dacey Rankins 2025-03-10 17:25:48 0 11KB
Научная фантастика и фэнтези
Бегущий по лезвию. Blade Runner. (1982)
Ноябрь 2019 года. Бывший охотник на андроидов Рик Декард восстановлен в полиции Лос-Анджелеса для...
Por Nikolai Pokryshkin 2023-03-17 14:58:57 0 32KB

BigMoney.VIP Powered by Hosting Pokrov