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

Поиск
Категории
Больше
Business
How Does Automation Improve Productivity?
Automation has become one of the most powerful drivers of productivity in modern workplaces. By...
От Dacey Rankins 2026-04-23 16:59:39 0 4Кб
Marketing and Advertising
What Are the Main Types of SEO?
Understanding On-Page, Off-Page, Technical, and Local SEO (and How They Work Together) Search...
От Dacey Rankins 2025-10-31 15:40:23 0 10Кб
Business
What is the Lean Startup Methodology?
In the fast-paced world of entrepreneurship, the Lean Startup methodology has become a...
От Dacey Rankins 2025-03-20 15:04:51 0 13Кб
Issues
Problem
Problema (ancient Greek: Problema) πρόβλημα - task, task) in a...
От FWhoop Xelqua 2023-04-19 17:27:03 0 17Кб
Economics
How does foreign investment affect economic development?
Foreign investment plays a crucial role in shaping the trajectory of economic development,...
От Leonard Pokrovski 2026-04-11 00:43:27 0 4Кб

BigMoney.VIP Powered by Hosting Pokrov