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
Business
How Do I Pitch Without Sounding Salesy?
One of the biggest fears presenters have — whether they’re startup founders,...
By Dacey Rankins 2025-12-03 15:47:54 0 3K
Научная фантастика и фэнтези
Звёздные войны: Эпизод 5 — Империя наносит ответный удар. Star Wars: Episode V - The Empire Strikes Back. (1980)
Борьба за Галактику обостряется в пятом эпизоде космической саги. Войска Императора начинают...
By Nikolai Pokryshkin 2022-11-12 13:20:55 0 35K
Marketing and Advertising
What Business Goals Should Our Marketing Strategy Align With?
A marketing strategy is not just about generating leads, running ads, or posting on social media....
By Dacey Rankins 2025-10-16 18:48:58 0 2K
Business
How Much Autonomy Should I Give My Team?
One of the most critical—and often misunderstood—leadership questions is:“Am I...
By Dacey Rankins 2025-07-17 14:27:19 0 5K
Business
How Do I Adapt My Communication for Different Audiences or Situations?
Introduction Effective communication is not a “one-size-fits-all” skill. The way we...
By Dacey Rankins 2025-11-20 15:18:54 0 2K

BigMoney.VIP Powered by Hosting Pokrov