String.prototype.match()

0
11KB

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
Nature and Science
Dream Horse (2021)
Dream Alliance is an unlikely race horse bred by small-town Welsh bartender Jan Vokes. With no...
Par Leonard Pokrovski 2022-09-07 13:52:42 0 37KB
Marketing and Advertising
What Industries Use Billboard Advertising the Most?
Billboard advertising has remained a powerful marketing channel for decades, even as digital...
Par Dacey Rankins 2026-01-14 14:25:31 0 691
Personal Finance
What Kinds of Retirement Plans Are There?
What Kinds of Retirement Plans Are There? A Guide to Defined-Benefit, Defined-Contribution, and...
Par Leonard Pokrovski 2025-11-25 21:43:48 0 2KB
Personal Finance
What Should I Do if I Find Errors on My Credit Report?
What Should I Do if I Find Errors on My Credit Report? Your credit report plays a vital role in...
Par Leonard Pokrovski 2025-10-23 10:27:19 0 6KB
Business
How Can I Improve a Poor Interview-to-Hire Ratio?
A poor interview-to-hire ratio means that you’re getting interviews but not converting them...
Par Dacey Rankins 2025-08-12 15:41:45 0 6KB

BigMoney.VIP Powered by Hosting Pokrov