String.prototype.match()

0
12KB

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

Rechercher
Catégories
Lire la suite
Business
What Role Does Customer Segmentation and Targeting Play in Product Strategy?
When it comes to building products that succeed, no company can serve “everyone.” The...
Par Dacey Rankins 2025-08-21 16:35:23 0 6KB
Productivity
Can focus be trained like a muscle?
Can Focus Be Trained Like a Muscle? The idea that “focus is like a muscle” has...
Par Michael Pokrovski 2026-04-18 06:10:49 0 17KB
Organizations
WHO: what is it, decoding, history of creation
WHO: what is it, decoding, history of creation World Health Day is celebrated annually...
Par Leonard Pokrovski 2024-04-20 21:42:38 0 17KB
Antiques and Collectibles
Unveiling the Timeless Appeal of Antiques and Collectibles
In today's fast-paced world where technology evolves at the blink of an eye, there's a certain...
Par Dacey Rankins 2024-05-28 17:31:18 0 22KB
Mental Health
Schizophrenia Risk Factors: Environmental and Substance Use
EnvironmentalEnvironmental factors, each associated with a slight risk of developing...
Par Kelsey Rodriguez 2023-01-31 15:41:02 0 15KB

BigMoney.VIP Powered by Hosting Pokrov