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

البحث
الأقسام
إقرأ المزيد
Marketing and Advertising
Should I Use Organic Posts, Paid Ads, or Both on Social Media?
One of the most common questions businesses and marketers face when planning their social media...
بواسطة Dacey Rankins 2025-11-03 15:03:28 0 14كيلو بايت
Financial Services
Decisions with a budged constraint
Key points The budget constraint is the boundary of...
بواسطة Mark Lorenzo 2023-02-13 15:15:43 0 17كيلو بايت
Business
Is Facility Management a Good Career?
Facility management is increasingly recognized as a strong and stable career path in...
بواسطة Dacey Rankins 2026-04-16 20:25:40 0 2كيلو بايت
Business
The Challenge of Educating Other Functions About Product Marketing
Product Marketing Managers (PMMs) are often masters of external communication—crafting...
بواسطة Dacey Rankins 2025-09-15 18:59:22 0 8كيلو بايت
Business
Profession PR manager (PR manager)
Who is a PR manager?A PR manager or PR manager (from the English public relations) is a...
بواسطة Dacey Rankins 2024-09-03 19:09:01 0 16كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov