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

Поиск
Категории
Больше
Programming
Java vs JavaScript
What is Java? Java is a statically typed object-based programming language. Its ability to run...
От Jesse Thomas 2023-06-08 21:18:53 0 11Кб
Marketing and Advertising
Common Mistakes to Avoid When Storytelling in Marketing
Storytelling has become one of the most powerful tools in modern marketing — a bridge...
От Dacey Rankins 2025-11-04 19:17:22 0 2Кб
Internet
Google ads: interface and settings
Definition Google Ads is an advertising platform for self-setting advertising campaigns with...
От FWhoop Xelqua 2023-01-30 17:35:11 0 20Кб
Marketing and Advertising
How Do I Become a Copywriter?
A Step-by-Step Guide to Building a Career in Persuasive Writing Copywriting is one of the most...
От Dacey Rankins 2025-09-30 16:02:38 0 4Кб
Business
What are the Primary Responsibilities of a COO?
The Chief Operating Officer (COO) is one of the most critical leadership roles within an...
От Dacey Rankins 2025-01-28 15:30:12 0 17Кб

BigMoney.VIP Powered by Hosting Pokrov