String.prototype.match()

0
8KB

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

Suche
Kategorien
Mehr lesen
Financial Services
Perfect competition and why it matters
Key points A perfectly competitive firm is a price taker, which means that it...
Von Mark Lorenzo 2023-04-25 19:18:12 0 10KB
Television
25 ABC Connecting Central Texas. KXXV. Live TV. USA.
KXXV (News Channel 25) is a full-power television station in Waco, Texas. It's serving Central...
Von Nikolai Pokryshkin 2022-10-11 11:03:17 0 47KB
Public Health and Safety
Public Health and Safety: Ensuring Community Well-Being
Public health and safety are fundamental aspects of a thriving society, encompassing the measures...
Von Dacey Rankins 2024-11-04 18:14:32 0 7KB
Television
WTNH News 8 Newscasts Live TV. New Haven, Connecticut, USA.
WTNH, channel 8, is an ABC-affiliated television station located in New Haven, Connecticut, USA....
Von Nikolai Pokryshkin 2022-11-08 19:34:30 0 23KB
Music
3 Lo-Fi Beats and Calming Visuals: A Serene Escape into Chill Vibes for Studying, Relaxing, Sleeping
🎧 3 Lo-Fi Beats to Power Your Day: Study, Relax, and Sleep In a world full of noise and...
Von Gpykin 2025-06-22 06:25:37 1 3KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov