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

Search
Categories
Read More
Financial Services
Law of Demand
Key points The law of demand states that a higher price leads to a lower...
By Mark Lorenzo 2023-01-25 14:05:14 0 17K
Personal Development
What are the best personal development books?
Personal development is a lifelong process of improving your mindset, skills, habits, and overall...
By Michael Pokrovski 2026-02-03 17:58:09 0 3K
Marketing and Advertising
What Types of Content Are Most Effective?
Maximizing Impact Through Strategic Content Formats In the fast-paced digital landscape, content...
By Dacey Rankins 2025-09-30 15:48:26 0 7K
Business
What Are Common Challenges Faced by Startups in Driving Innovation?
Driving innovation is at the heart of every startup’s mission. Whether it's launching a...
By Dacey Rankins 2025-03-21 14:14:24 0 18K
Productivity
How to read fast and understand?
Reading fast and understanding simultaneously is a matter of active engagement. To maintain...
By Michael Pokrovski 2026-05-07 17:02:00 0 2K

BigMoney.VIP Powered by Hosting Pokrov