String.prototype.match()

0
12KB

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
Ужасы
Дальний космос. Stowaway (2021)
Экипаж космического корабля, направляющегося на Марс, обнаруживает на борту случайного пассажира...
Por Nikolai Pokryshkin 2022-09-18 22:13:39 0 68KB
Illustration
How to earn money through illustration
What will you need to make money on drawings on the Internet? Before you learn how to make money...
Por FWhoop Xelqua 2022-10-04 14:57:43 0 35KB
Business
What Is the Role of Business Development in Startups vs. Established Companies?
Introduction Business development (BizDev) plays a vital role in the growth, sustainability and...
Por Dacey Rankins 2025-11-17 18:34:08 0 5KB
Economics
What is the economic impact of global warming?
What Is the Economic Impact of Global Warming? The first thing to disappear is not the glacier....
Por Leonard Pokrovski 2026-05-28 21:49:49 0 3KB
Economics
What Is the Relationship Between Inequality and Development?
What Is the Relationship Between Inequality and Development? The relationship between inequality...
Por Leonard Pokrovski 2026-04-11 17:45:59 0 2KB

BigMoney.VIP Powered by Hosting Pokrov