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

Pesquisar
Categorias
Leia Mais
Business and Corporate Finance
How Does Corporate Finance Manage Risk?
How Does Corporate Finance Manage Risk? Hedging, Diversification, and Financial Controls...
Por Leonard Pokrovski 2026-01-21 19:26:25 0 2K
Business
How Do I Find Leads?
Finding leads is one of the most important skills in sales. Without leads, you have no one to...
Por Dacey Rankins 2025-12-12 17:02:00 0 4K
Consultants
The Role of Computer Consultants: Helping Businesses Navigate the Digital Age
In today’s fast-paced, technology-driven world, businesses of all sizes rely heavily on...
Por Dacey Rankins 2024-11-19 18:17:39 0 11K
Productivity
What is Time Blocking?
What is Time Blocking? Time blocking is a time management technique that involves dividing your...
Por Michael Pokrovski 2026-02-16 21:48:53 0 1K
Knives
A Comprehensive Guide to Knives: Types, Uses, and Safety
Knives are among the most essential tools used by humans, serving a wide variety of functions in...
Por Dacey Rankins 2024-11-26 14:51:38 0 11K

BigMoney.VIP Powered by Hosting Pokrov