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

Suche
Kategorien
Mehr lesen
Cooking
Rabbit salad with ham, rice, corn and cucumber
Surprise guests with an unusual dish for the New Year. Salad "Rabbit" with corn, rice and ham, as...
Von FWhoop Xelqua 2022-12-05 16:51:39 0 20KB
Finance
How Does Fintech Compare with Traditional Banking or Financial Services?
How Does Fintech Compare with Traditional Banking or Financial Services? Introduction In the...
Von Leonard Pokrovski 2025-10-10 22:52:56 0 3KB
Ethics
Problems of Ethics and Security in the Information System
Information systems have made many businesses successful today. Some companies, such as Google,...
Von Dacey Rankins 2024-03-22 17:56:23 0 25KB
Financial Services
Macroeconomic perspectives on demand and supply
Key points Keynes’ Law states that demand creates its own supply....
Von Mark Lorenzo 2023-03-13 20:40:21 0 13KB
Support Groups
How do I organize a support group?
In this article, we will talk mainly about the so-called peer support groups, in which...
Von FWhoop Xelqua 2023-02-06 15:57:58 0 21KB

BigMoney.VIP Powered by Hosting Pokrov