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

Pesquisar
Categorias
Leia mais
Business
How Do I Create Urgency or Prompt Action During Closing?
Creating urgency during the closing phase is essential for converting interest into commitment....
Por Dacey Rankins 2025-11-19 20:13:28 0 1KB
Television
FOX 35 Tropical Storm Ian strengthens, projected to make landfall in Florida as a hurricane. Live TV. Orlando, Florida, USA.
Florida is within the storm's projected path. As we wait for the official track, here are live...
Por Nikolai Pokryshkin 2022-09-24 12:03:15 0 35KB
Programming
String.prototype.match()
A regular expression object, or any object that has a Symbol.match method....
Por Jesse Thomas 2023-05-31 22:12:41 0 11KB
Business
What Is Logistics in Management Science?
Management of Flow of Goods, Services, or People Using Optimization, Analytics, Scheduling, etc....
Por Dacey Rankins 2025-07-03 18:01:55 0 5KB
Programming
How the Python or Operator Works
With the Boolean OR operator, you can connect two Boolean expressions into one compound...
Por Jesse Thomas 2023-03-06 23:53:35 0 12KB

BigMoney.VIP Powered by Hosting Pokrov