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
Nursing
Nursing
Nursing Patient care is a set of measures to serve patients (limited in...
Par Leonard Pokrovski 2024-04-17 18:33:52 0 19KB
Спорт
Убить Билла 1-2. Kill Bill: Vol. 1 - 2. (2003-2004)
Убить Билла 1. Kill Bill: Vol. 1. (2003)В беременную наемную убийцу по кличке Черная Мамба во...
Par Nikolai Pokryshkin 2023-02-23 18:52:53 0 25KB
Social Issues
North by Northwest. (1959)
A New York City advertising executive goes on the run after being mistaken for a government agent...
Par Leonard Pokrovski 2023-01-17 19:04:53 0 23KB
Business
How Does CRO Align with SEO and Content Marketing?
In digital marketing, strategies often operate in silos: SEO teams focus on visibility, content...
Par Dacey Rankins 2025-09-11 16:22:42 0 5KB
Business
How Can Communication Style Be Adapted to Different Personalities?
In today’s diverse and dynamic workplace, one-size-fits-all communication rarely works....
Par Dacey Rankins 2025-08-05 14:59:07 0 5KB

BigMoney.VIP Powered by Hosting Pokrov