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
Personal Finance
How Often Should I Review My Financial Plan?
How Often Should I Review My Financial Plan? How Often Should I Meet with My Adviser, and When...
By Leonard Pokrovski 2025-11-05 15:54:54 0 8K
Productivity
Is procrastination related to ADHD?
Is Procrastination Related to ADHD? Procrastination is a widespread behavior, often framed as a...
By Michael Pokrovski 2026-04-24 10:19:56 0 2K
Business
How to Get Traffic to Affiliate Links
Affiliate marketing has an image problem. From a distance, it looks deceptively mechanical:pick...
By Dacey Rankins 2026-05-16 21:47:55 0 890
Business
Do I Need a Business Plan?
When starting a business, one of the first questions you may ask is whether you need a business...
By Dacey Rankins 2025-02-06 15:16:25 0 27K
Business
What are the current trends in content creation, and how can I incorporate them?
In the world of content creation, staying ahead of trends is crucial for maintaining relevance...
By Dacey Rankins 2025-02-21 15:09:39 0 16K

BigMoney.VIP Powered by Hosting Pokrov