String.prototype.match()

0
11Кб

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

Поиск
Категории
Больше
Middle East
Top 10 attractions in the Middle East
But did you know that the Middle East is made up of 14 different...
От FWhoop Xelqua 2023-03-08 14:45:39 0 19Кб
Business
How Affiliate Marketing Works: A Guide for Those Who Dive Into the Topic
How Affiliate Marketing Works: A Guide for Those Who Dive Into the Topic Customer...
От Leonard Pokrovski 2024-08-30 20:06:05 0 28Кб
Business
How Do I Legally Register a Startup?
Starting a business is an exciting and rewarding journey, but before you dive into the world of...
От Dacey Rankins 2025-04-09 14:08:11 0 10Кб
Business
What is recruiting and what do recruiters do: a starter guide
What is recruiting and what do recruiters do: a starter guide  ...
От Leonard Pokrovski 2024-08-14 17:31:07 0 24Кб
Business
How does the CEO handle failure? Insights into the CEO's approach to setbacks can offer valuable lessons in resilience and adaptability.
In the high-stakes world of corporate leadership, failure is inevitable. Even the most successful...
От Dacey Rankins 2025-07-01 19:51:43 0 5Кб

BigMoney.VIP Powered by Hosting Pokrov