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
Segurança
Understanding Computer Security: Protecting Your Digital World
In today’s increasingly digital world, computer security has become an essential aspect of...
Por Dacey Rankins 2025-01-20 16:12:21 0 14KB
Economics
What is the purpose of comparative economics?
Comparative economics is the branch of economics that studies how different economic systems...
Por Leonard Pokrovski 2026-03-02 19:58:22 0 3KB
Mental Health
ADHD: Suicide Risk
Systematic reviews conducted in 2017 and 2020 found strong evidence that ADHD is associated with...
Por Kelsey Rodriguez 2023-03-30 16:38:10 0 13KB
Business
What Is a Business Biography?
A business biography is a detailed account of a person’s career and professional...
Por Dacey Rankins 2024-12-27 15:56:10 0 18KB
Business
What to do if you have a mobile app idea: a beginner's guide.
What to do if you have a mobile app idea: a beginner's guide. One fine morning, you wake up with...
Por Leonard Pokrovski 2024-08-28 22:25:54 0 22KB

BigMoney.VIP Powered by Hosting Pokrov