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
What’s a Habit I Can Develop to Improve My Life?
  If there’s one truth about self-improvement, it’s that big change comes from...
από Dacey Rankins 2025-09-08 08:08:52 0 7χλμ.
Business
What is Business Strategy? A Clear Definition and Examples
Business strategy is a crucial concept that defines how a company will achieve its long-term...
από Dacey Rankins 2024-12-23 16:01:27 0 12χλμ.
Economics
What is the current state of the economy?
The current state of the global economy in 2026 can best be described as resilient but fragile....
από Leonard Pokrovski 2026-03-28 05:21:21 0 2χλμ.
Productivity
How to build a reading habit?
How to Build a Reading Habit? A reading habit is often treated like a personality trait. People...
από Michael Pokrovski 2026-05-23 23:45:59 0 710
Business
A User Story is Just a Placeholder for a Conversation
In Agile development, user stories are often misunderstood. Many people treat them as...
από Dacey Rankins 2025-08-26 12:26:36 0 14χλμ.

BigMoney.VIP Powered by Hosting Pokrov