String.prototype.match()

0
11K

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

Search
Categories
Read More
Television
Medibiz TV. Live TV, Dubai - United Arab Emirates. (English)
Medi BizTV is a 24 hour free to air satellite TV channel dedicated to serve and spread the...
By Nikolai Pokryshkin 2023-03-04 15:05:40 0 50K
Business
How Do I Give Effective Feedback?
Giving effective feedback is an essential skill in both personal and professional relationships....
By Dacey Rankins 2025-07-29 17:22:18 0 6K
Journals
Unlocking the Power of Journal References: A Comprehensive Guide
Unlocking the Power of Journal References: A Comprehensive Guide In...
By Leonard Pokrovski 2024-05-18 18:56:11 0 17K
Business
What is Google Analytics 4 (GA4)?
Google Analytics 4, commonly referred to as GA4, is Google’s latest analytics platform that...
By Dacey Rankins 2025-09-01 09:24:11 0 3K
Social Issues
Modern Times. (1936)
The Tramp struggles to live in modern industrial society with the help of a young homeless woman....
By Leonard Pokrovski 2022-12-07 21:14:56 0 22K

BigMoney.VIP Powered by Hosting Pokrov