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

Поиск
Категории
Больше
Social Issues
A Christmas Gift from Bob (2020)
A struggling street musician finds himself the target of an animal welfare investigation that...
От Leonard Pokrovski 2022-10-07 22:30:32 0 28Кб
Business
Who is a COO?
1. Brief History of the COO Profession: The COO profession is relatively recent. At the...
От Dacey Rankins 2024-07-19 19:49:50 0 21Кб
Finance
The Main Types and Segments of Fintech
The Main Types and Segments of Fintech Introduction Financial technology—better known as...
От Leonard Pokrovski 2025-10-09 17:29:32 0 3Кб
Business
The Most Common Mistakes People Make With Table & Dining Etiquette: A Comprehensive, Professional Guide
Dining etiquette has existed for centuries, not because societies enjoy rigid rules, but because...
От Dacey Rankins 2025-11-21 17:27:45 0 2Кб
Социальные проблемы
Афера. The Sting. (1973)
В 1930-е годы двое отпетых мошенников пытаются отомстить главарю мафии за смерть их общего друга...
От Nikolai Pokryshkin 2023-01-24 08:52:46 0 34Кб

BigMoney.VIP Powered by Hosting Pokrov