String.prototype.match()

0
11KB

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

Suche
Kategorien
Mehr lesen
Marketing and Advertising
What Makes a Good PR Agency — and How to Choose a PR Firm That Fits Your Brand
Introduction: The Power of the Right PR Partner In today’s fast-moving, reputation-driven...
Von Dacey Rankins 2025-10-27 17:24:16 0 2KB
Finance
Are There Finance Biographies Focused on Female Financiers and Underrepresented Groups?
Are There Finance Biographies Focused on Female Financiers and Underrepresented Groups? In the...
Von Leonard Pokrovski 2025-10-08 20:41:01 0 5KB
Television
CGTN news (English) Live TV from China.
CGTN news, China Central Television (former CCTV 9) is a 24/7 news TV channel in the English...
Von Nikolai Pokryshkin 2022-08-29 20:56:10 0 34KB
Mental Health
Dementia: Pre-dementia
Pre-dementia states include pre-clinical and prodromal stages. The prodromal stages includes (1)...
Von Kelsey Rodriguez 2023-07-17 17:52:05 0 15KB
Business
What Is Product Management?
Product management is a discipline focused on guiding the development, launch, and growth of...
Von Dacey Rankins 2025-08-15 20:31:22 0 4KB

BigMoney.VIP Powered by Hosting Pokrov