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

Buscar
Categorías
Read More
Agriculture
Agricultural Sciences
Agricultural sciences are a broad, interdisciplinary field that encompasses parts of the exact,...
By FWhoop Xelqua 2023-04-18 18:07:48 0 18K
Business
Understanding Market Competition and Its Impact on Business and Economics
Market competition plays a fundamental role in shaping the behavior of businesses and the...
By Dacey Rankins 2025-01-13 14:53:05 0 11K
Социальные проблемы
Побег из Шоушенка. The Shawshank Redemption. (1994)
Бухгалтер Энди Дюфрейн обвинён в убийстве собственной жены и её любовника. Оказавшись в тюрьме...
By Nikolai Pokryshkin 2022-10-24 13:34:22 0 30K
Personal Finance
Myths and Misconceptions About Credit Repair.
Credit repair often gets a bad rap and is riddled with myths that can discourage people from...
By Dacey Rankins 2024-10-23 16:18:07 0 20K
Finance
What Is a Cash Advance?
What Is a Cash Advance? A cash advance is a short-term loan feature offered by credit card...
By Leonard Pokrovski 2025-10-05 19:29:10 0 1K

BigMoney.VIP Powered by Hosting Pokrov