String.prototype.match()

0
12Кб

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

Поиск
Категории
Больше
Personal Finance
What Deductions Are Taken From My Paycheck?
What Deductions Are Taken From My Paycheck? (Tax, Health Insurance, Pension, Social Security,...
От Leonard Pokrovski 2025-12-01 21:37:31 0 11Кб
Социальные проблемы
Рай и ад. High and Low. (1963)
Преуспевающий бизнесмен должен решить для себя, заплатит ли он выкуп похитителям, которые по...
От Nikolai Pokryshkin 2023-01-08 22:19:53 0 24Кб
Business
How Can Communication Style Be Adapted to Different Personalities?
In today’s diverse and dynamic workplace, one-size-fits-all communication rarely works....
От Dacey Rankins 2025-08-05 14:59:07 0 9Кб
Suburban Living
How to make a pond
An artificial pond is a decorative design element of any suburban area. Garden pond is a habitat...
От FWhoop Xelqua 2022-12-01 18:40:36 0 24Кб
Economics
What Is Fiscal Policy?
What Is Fiscal Policy? Fiscal policy is one of the main tools governments use to influence a...
От Leonard Pokrovski 2026-01-27 18:51:11 0 4Кб

BigMoney.VIP Powered by Hosting Pokrov