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

Site içinde arama yapın
Kategoriler
Read More
Marketing and Advertising
How Much Can the Average Distributor Earn (or What Is the Average Income?)
Introduction Multilevel marketing (MLM) often promises financial freedom, flexible hours, and...
By Dacey Rankins 2025-10-20 17:12:14 0 5K
Business
The Business Development Timeline: How Long It Takes to See Real Results
Executives want results now.Founders want results yesterday.Boards want results before the next...
By Dacey Rankins 2025-11-18 15:45:07 0 2K
Finance
What Is Leverage and Margin in Forex? Understanding the Power and Risks
What Is Leverage and Margin in Forex? Understanding the Power and Risks Foreign exchange (Forex...
By Leonard Pokrovski 2025-10-16 19:14:55 0 3K
Mental Health
ADHD: Social construct theory
The social construct theory of ADHD suggests that, because the boundaries between normal and...
By Kelsey Rodriguez 2023-04-21 14:14:43 0 11K
Marketing and Advertising
What Makes a Good PR Agency — and How to Choose a PR Firm That Fits Your Brand
Introduction: The Power of the Right PR Partner In today’s fast-moving, reputation-driven...
By Dacey Rankins 2025-10-27 17:24:16 0 2K

BigMoney.VIP Powered by Hosting Pokrov