String.prototype.match()

0
12K

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 Is Good–Better–Best (Tiered) Pricing?
When businesses want to appeal to a broad range of customers while maximizing revenue, they often...
By Dacey Rankins 2025-09-04 12:17:08 0 7K
Personal Finance
What If I Overspend?
What If I Overspend? How to Regain Control and Restore Balance to Your Budget Everyone has been...
By Leonard Pokrovski 2025-10-22 12:42:43 0 4K
Personal Development
How long does personal development take?
How Long Does Personal Development Take? One of the most common questions people ask when they...
By Michael Pokrovski 2026-02-12 14:54:08 0 2K
Business
How Do I Measure the Success of a Business Consulting Engagement?
When hiring a business consultant, companies invest not just in external expertise but in the...
By Dacey Rankins 2025-02-11 15:58:26 0 18K
Социальные проблемы
Охота. The Hunt. (2020)
Несколько человек имели неосторожность обсуждать в групповом чате охоту на людей. Некоторое время...
By Nikolai Pokryshkin 2022-10-22 16:28:04 0 32K

BigMoney.VIP Powered by Hosting Pokrov