String.prototype.match()

0
7K

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

Site içinde arama yapın
Kategoriler
Read More
Business
What Are Effective Marketing Strategies for Startups?
Marketing is one of the most important components of growing a successful startup. For many...
By Dacey Rankins 2025-03-05 16:30:38 0 3K
Museums and Archives
Preserving History: A Glimpse into the Latest from Museums and Archives
Preserving History: A Glimpse into the Latest from Museums and Archives Museums and archives are...
By Leonard Pokrovski 2024-05-06 17:46:30 0 12K
Social Issues
The Wolf of Wall Street. (2013)
Based on the true story of Jordan Belfort, from his rise to a wealthy stock-broker living the...
By Leonard Pokrovski 2023-02-09 14:36:26 0 14K
Crafts
The World of Art Crafts: Creativity, Culture, and Craftsmanship
Art crafts, often referred to as "handicrafts," represent a broad and diverse range of creative...
By Dacey Rankins 2024-12-13 14:32:49 0 4K
Television
Live TV, Channel 2 KWGN-TV in Denver, Colorado, USA
Watch live local news and shows from Channel 2 KWGN-TV in Denver, Colorado. When no broadcasts...
By Nikolai Pokryshkin 2022-10-18 09:21:14 0 23K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov