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

Căutare
Categorii
Citeste mai mult
Marketing and Advertising
Do I Need a Website to Start Affiliate Marketing?
When people first hear about affiliate marketing, their assumption is often that they’ll...
By Dacey Rankins 2025-09-18 16:05:01 0 6K
Biology
Biology
Biology (Greek: βιολογία; from Ancient Greek:...
By FWhoop Xelqua 2023-03-03 16:42:32 0 22K
Mental Health
Dyslexia: classification
Dyslexia is divided into developmental and acquired forms. Acquired dyslexia occurs subsequent to...
By Kelsey Rodriguez 2023-06-13 19:40:50 0 11K
Marketing and Advertising
How Long Does It Take to See Results from SEO?
Understanding the Real Timelines, Variables, and Expectations Behind Organic Growth One of the...
By Dacey Rankins 2025-10-31 15:38:51 0 6K
Business
How Can Communication Style Be Adapted to Different Personalities?
In today’s diverse and dynamic workplace, one-size-fits-all communication rarely works....
By Dacey Rankins 2025-08-05 14:59:07 0 5K

BigMoney.VIP Powered by Hosting Pokrov