String.prototype.match()

0
4K

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

Search
Categories
Read More
Financial Services
How the AD/AS model incorporates growth, unemployment, and inflation
Key points The aggregate demand/aggregate supply, or AD/AS, model is one of the...
By Mark Lorenzo 2023-03-31 19:57:02 0 6K
Yard, Deck, and Table Games
Yard, Deck, and Table Games: Classic Fun for All Ages
Games have always been a great way to bring people together, whether you’re enjoying a...
By Dacey Rankins 2024-12-05 14:45:29 0 2K
Business
Organizing Chart: Hats and What's Underneath?
Do we really need structure... It is good if everything works smoothly in the company: work...
By Dacey Rankins 2024-09-23 14:40:42 0 7K
Holidays
TOP 5 of the strangest holidays
1. Festival of colors in India Every year in March, Hindus celebrate holi - an ancient festival...
By FWhoop Xelqua 2023-01-07 15:16:07 0 10K
Hacking
Hacking as a business. Is it possible to make money from this?
Hello, dear friends. Hacking, the illegal use of computer technology to gain unauthorized access...
By Michael Pokrovski 2024-03-25 20:41:23 0 14K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov