String.prototype.match()

0
11K

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

Cerca
Categorie
Leggi tutto
Business
What Are the Main Skills and Techniques Needed for Conflict Resolution?
Effective conflict resolution relies on a combination of interpersonal skills and proven...
By Dacey Rankins 2025-08-04 18:28:48 0 3K
Shopping
Best Computers of 2022
The computer has long been an integral part of the life of modern man. These devices vary in...
By FWhoop Xelqua 2022-10-30 17:39:51 0 33K
Art History
Art History
Principles of periodization and the structure of the general history of art as a scienceWithin...
By FWhoop Xelqua 2023-06-21 16:17:01 0 32K
Death Care
The Evolving Landscape of Death Care: Honoring Departed Loved Ones
In the grand tapestry of life, death is an inevitable thread. How we approach the end of life and...
By Dacey Rankins 2024-05-29 19:10:38 0 20K
Personal Finance
How to Create a Budget and Save Money: A Practical Guide to Managing Income, Expenses, and Spending
How to Create a Budget and Save Money: A Practical Guide to Managing Income, Expenses, and...
By Leonard Pokrovski 2025-11-18 21:12:47 0 865

BigMoney.VIP Powered by Hosting Pokrov