String.prototype.match()

0
11KB

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

Suche
Kategorien
Mehr lesen
Marketing and Advertising
What Does a PR Professional Do? Roles, Skills, and Impact Explained
Introduction: The Unsung Heroes of Brand Reputation Every successful brand has one thing in...
Von Dacey Rankins 2025-10-24 16:05:56 0 3KB
Marketing and Advertising
How Much Does Influencer Marketing Cost? / How Much Do Influencers Charge?
Understanding pricing, factors, and budgeting for influencer campaigns Introduction: The Cost...
Von Dacey Rankins 2025-10-07 17:47:06 0 6KB
Business
Where Do You See Yourself in Five Years?
This Gauges Ambition and Whether the Candidate's Career Goals Align with the Company's Trajectory...
Von Dacey Rankins 2025-06-18 14:56:17 0 7KB
Business
What Is Passive Income?
In the world of business and personal finance, "passive income" is a term that often sparks...
Von Dacey Rankins 2025-01-14 14:55:44 0 20KB
Business
Customer Feedback Surveys: "How satisfied are you with our service?" or "What can we improve?"
In today’s competitive market, understanding customer experiences is more crucial than...
Von Dacey Rankins 2025-05-29 14:45:20 0 13KB

BigMoney.VIP Powered by Hosting Pokrov