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

Rechercher
Catégories
Lire la suite
Personal Finance
What Are the Tax Advantages of Real Estate Investing?
What Are the Tax Advantages of Real Estate Investing? Real estate investing is often described...
Par Leonard Pokrovski 2025-12-24 18:15:04 0 12KB
Decision Making and Problem Solving
Why is lateral thinking important in education?
The Architecture of the Intellectual Pivot The mind is a pattern-making machine. It is...
Par Michael Pokrovski 2026-07-09 09:58:29 0 581
Whips
The Art of Recreation: Exploring the Craft of Whip Making
The Art of Recreation: Exploring the Craft of Whip Making Whips have a storied history,...
Par Leonard Pokrovski 2024-05-17 00:10:48 0 20KB
Жизненные вопросы
Головоломка. Inside Out. (2016)
Райли — обычная 11-летняя школьница, и, как у каждого из нас, ее поведение определяют пять...
Par Nikolai Pokryshkin 2023-03-05 14:55:29 0 41KB
Economics
How do I calculate interest on savings?
A savings account is one of the simplest ways to grow your money over time. The interest you earn...
Par Leonard Pokrovski 2026-08-02 22:06:55 0 5KB

BigMoney.VIP Powered by Hosting Pokrov