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

Rechercher
Catégories
Lire la suite
Sport
Senna (2010)
A documentary on Brazilian Formula One racing driver Ayrton Senna, who won the F1 world...
Par Leonard Pokrovski 2023-07-04 19:54:58 0 29KB
Business and Corporate Finance
What Are the Responsibilities of a CFO?
What Are the Responsibilities of a CFO?Key Duties and Core Functions The Chief Financial Officer...
Par Leonard Pokrovski 2026-01-11 05:52:08 0 3KB
Finance
What Are Interest Rates?
What Are Interest Rates? Interest rates play a fundamental role in the world of finance and...
Par Leonard Pokrovski 2025-10-05 19:30:01 0 5KB
Business
What is Business Ethics?
Business ethics is a field of study that deals with the principles, standards, and moral...
Par Dacey Rankins 2025-01-30 15:58:17 0 13KB
Business
Top 3 Mistakes in Presenting Your Product
Let's figure out what not to do to find and get your business angel. Let's list the most common...
Par Dacey Rankins 2024-09-13 14:21:50 0 13KB

BigMoney.VIP Powered by Hosting Pokrov