String.prototype.match()

0
8χλμ.

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

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Guns
Exploring the Recreational Side of Firearms: More than Just Shooting
Exploring the Recreational Side of Firearms: More than Just Shooting Introduction: Firearms have...
από Leonard Pokrovski 2024-05-09 09:56:54 0 14χλμ.
Healthcare
Stress ball Benefits
The Health Benefits of Stress Balls  Stress balls were originally intended to be used for...
από FWhoop Xelqua 2023-05-21 17:34:07 0 18χλμ.
Travel
Named the most visited attractions in the world
The authoritative publication Travel + Leisure has published a list of the main tourist...
από FWhoop Xelqua 2023-01-03 14:47:15 0 19χλμ.
Ιστορίες
The History of Games: From Ancient Play to Digital Masterpieces
Games have been an integral part of human culture for thousands of years. From the earliest forms...
από Dacey Rankins 2024-11-25 14:35:28 0 6χλμ.
Business
How Should I Split Equity with Co-Founders?
Equity distribution is one of the most critical and potentially sensitive decisions a founding...
από Dacey Rankins 2025-05-01 16:20:49 0 4χλμ.
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov