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
How to Assess the Viability of a Startup: Analyzing the Business Model Canvas
How to Assess the Viability of a Startup: Analyzing the Business Model Canvas Business Model...
Por Leonard Pokrovski 2024-07-18 17:46:33 0 26K
Business
What Are the Best Small Business Loans or Grants Available?
Starting or expanding a small business often requires financial support. Fortunately, various...
Por Dacey Rankins 2025-03-14 16:10:16 0 14K
Marketing and Advertising
How Long Should My Marketing Videos Be? Finding the Perfect Duration for Every Platform and Purpose
Introduction Video is one of the most engaging and effective forms of marketing content today,...
Por Dacey Rankins 2025-11-07 20:08:40 0 5K
Television
TCT Live TV. Marion, Illinois, United States.
Take a look at the TCT Network and you will find award-winning exclusive programming, live...
Por Nikolai Pokryshkin 2022-11-21 18:17:44 0 37K
Business
What Skills Do You Need for Sales?
Sales is not about being “born persuasive” or having a certain personality. Sales is...
Por Dacey Rankins 2025-12-15 17:21:10 0 1K

BigMoney.VIP Powered by Hosting Pokrov