String.prototype.match()

0
8K

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

Site içinde arama yapın
Kategoriler
Read More
Arts
Investments in art. How much can you earn from masterpieces?
Works of art, in addition to cultural value, also have material value. Moreover, their value is...
By Michael Pokrovski 2024-03-11 21:17:45 0 21K
Domestic Services
20 most popular jobs
Over time, interest in some services is falling, and for others, consumer demand is increasing....
By FWhoop Xelqua 2022-11-28 14:59:39 0 36K
Television
CBS, WIVB 4 Live TV. Buffalo, New York, United States.
WIVB-TV, (UHF digital channel 39), is a CBS-affiliated television station located in Buffalo, New...
By Nikolai Pokryshkin 2022-11-03 10:26:05 0 38K
Business
Inspirational Checklist: 25 Things to Try If You Want to Change Your Life
  The list was compiled by psychologists, coaches and personal growth...
By Leonard Pokrovski 2024-07-16 17:38:34 0 16K
Business
How to Drive Ecommerce Growth Through Conversion Rate Optimization
How to Drive Ecommerce Growth Through Conversion Rate Optimization Think of your...
By Leonard Pokrovski 2024-08-27 16:03:40 0 21K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov