String.prototype.match()

0
12K

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
Life Issues
Inception (2010)
A thief who steals corporate secrets through the use of dream-sharing technology is given the...
Por Leonard Pokrovski 2022-11-12 20:59:30 0 29K
Marketing and Advertising
How Do I Measure Billboard Advertising ROI?
One of the most common criticisms of billboard advertising is that it is difficult to measure....
Por Dacey Rankins 2026-01-14 14:31:35 0 7K
Personal Finance
Why do you need financial consulting?
Few entrepreneurs use financial planning and analysis of activities.  With the help of...
Por Dacey Rankins 2024-10-28 16:19:04 0 13K
Business
Product marketing: what is it and why is it needed in IT  
Product marketing: what is it and why is it needed in IT   Launching a new product on...
Por Leonard Pokrovski 2024-08-28 21:41:43 0 23K
Business
Top 10 economies in terms of GDP by 2038
Top 10 economies in terms of GDP by 2038 In 2024, global...
Por Leonard Pokrovski 2024-07-24 12:41:02 0 19K

BigMoney.VIP Powered by Hosting Pokrov