String.prototype.match()

0
12χλμ.

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

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Business
Do I Need a Co-Founder to Start a Business?
One of the most common questions aspiring entrepreneurs ask is whether they need a co-founder to...
από Dacey Rankins 2025-04-07 17:35:19 0 18χλμ.
Programming
JavaScript Library
In the past, you would create a new file, paste your code and place this file in every project...
από Jesse Thomas 2023-06-09 21:35:17 0 12χλμ.
Marketing and Advertising
What Is a Press Release? Understanding Its Purpose, Power, and Best Practices
Introduction: The Timeless Tool of Communication In an era dominated by social media posts,...
από Dacey Rankins 2025-10-28 16:51:33 0 6χλμ.
Business
What Are the Main Causes of Conflict?
Conflicts can arise due to personality differences, miscommunication, competition for resources,...
από Dacey Rankins 2025-06-04 14:18:35 0 7χλμ.
Business
What Are Your Strengths and Weaknesses?
This Assesses Self-Awareness and Honesty In almost every job interview, candidates face the...
από Dacey Rankins 2025-06-18 14:52:38 0 13χλμ.

BigMoney.VIP Powered by Hosting Pokrov