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

Căutare
Categorii
Citeste mai mult
Телевидение
«Охотник и рыболов» - ТВ прямой эфир.
«Охотник и рыболов» - отличный выбор для тех, кому нравится природа, и просто для...
By Nikolai Pokryshkin 2022-10-27 12:03:57 0 39K
Marketing and Advertising
How Do I Keep My Vlog Interesting and Grow My Audience?
Introduction Keeping a vlog engaging while steadily growing an audience is one of the biggest...
By Dacey Rankins 2025-11-12 15:38:51 0 1K
Business
How Do I Manage Stage Fright?
Stage fright is one of the most common human experiences. Students, adults, teachers, performers,...
By Dacey Rankins 2025-12-11 16:36:37 0 7K
Personal Finance
What Happens If I Miss a Payment?
What Happens If I Miss a Payment? Understanding the Consequences: Late Fees, Credit Impact, and...
By Leonard Pokrovski 2025-11-06 19:21:14 0 7K
Business
What Brings Me Peace or Fulfillment Right Now?
Life often moves so quickly that we rarely pause to ask ourselves: What brings me peace or...
By Dacey Rankins 2025-09-09 14:25:53 0 7K

BigMoney.VIP Powered by Hosting Pokrov