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

Pesquisar
Categorias
Leia Mais
Marketing and Advertising
What Is the “Do Not Call” Registry and How Does It Work? Understanding Your Rights and Business Obligations
Introduction Telemarketing can be an effective channel for businesses, but it has also been one...
Por Dacey Rankins 2025-11-05 14:49:09 0 3K
Chemistry
TOP 10 discoveries and events in the chemical industry in 2021
Another difficult year is behind us. Political, socio-economic and climatic changes every day...
Por FWhoop Xelqua 2023-01-25 16:19:56 0 25K
Marketing and Advertising
Is My Business Considered Telemarketing? Understanding What Qualifies and Why It Matters
Introduction Many organizations engage in telephone-based outreach — calling customers,...
Por Dacey Rankins 2025-11-05 14:39:43 0 7K
Business
The Top 20 Project Management Questions I Get Asked Most Often
Over the years of working in project management, one thing has become clear—whether I'm...
Por Dacey Rankins 2025-05-19 14:44:28 0 12K
Marketing and Advertising
How Do I Pitch to Journalists? A Complete Guide to Successful Media Outreach
Introduction: The Art and Science of the Perfect Pitch In an era of constant information...
Por Dacey Rankins 2025-10-27 17:17:33 0 6K

BigMoney.VIP Powered by Hosting Pokrov