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

Search
Categories
Read More
Photography
Photography
Photography art is the photography-based art of creating a photograph that reflects the creative...
By FWhoop Xelqua 2023-07-13 19:56:40 0 24K
Television
CBN News The Christian Perspective. Live TV. USA.
Stay informed on world breaking news from a Christian perspective - CBN News brings you...
By Nikolai Pokryshkin 2022-11-18 12:15:48 0 59K
Marketing and Advertising
What Are the Types of Radio Advertising?
Radio advertising is not limited to simple recorded commercials. Modern radio campaigns use...
By Dacey Rankins 2026-02-06 19:30:13 0 4K
Marketing and Advertising
What Is Guerrilla Marketing? Definition, Core Principles, and Modern Applications
Introduction Marketing has always been about grabbing attention — but in today’s...
By Dacey Rankins 2025-10-07 14:54:22 0 12K
Customer Service
How Do I Train Employees for Better Customer Experience?
Employees play a critical role in shaping customer experience (CX). Whether interacting directly...
By Dacey Rankins 2026-03-06 20:09:31 0 8K

BigMoney.VIP Powered by Hosting Pokrov