String.prototype.match()

0
12كيلو بايت

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

البحث
الأقسام
إقرأ المزيد
Science Fiction and Fantasy
Avengers: Endgame. (2019)
After the devastating events of Avengers: Infinity War (2018), the universe is in ruins. With the...
بواسطة Leonard Pokrovski 2023-01-03 21:03:41 0 30كيلو بايت
Социальные проблемы
Афера. The Sting. (1973)
В 1930-е годы двое отпетых мошенников пытаются отомстить главарю мафии за смерть их общего друга...
بواسطة Nikolai Pokryshkin 2023-01-24 08:52:46 0 36كيلو بايت
Music
8 Calming Acoustic Music Sessions with Soft Drums for a Serene Atmosphere of Focus and Relaxation
In today’s fast-paced world, finding a moment of peace can feel like a luxury. Whether...
بواسطة Gpykin 2025-07-27 10:35:25 0 21كيلو بايت
Business
How Would You Describe Your Management or Leadership Style?
One of the most common and insightful questions in leadership and management discussions is:...
بواسطة Dacey Rankins 2025-08-05 15:09:46 0 9كيلو بايت
Marketing and Advertising
When and How Should a Brand Reposition (or Update Positioning)?
Introduction: The Constant Evolution of Perception No brand exists in a vacuum. Markets shift,...
بواسطة Dacey Rankins 2025-10-24 15:55:32 0 3كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov