String.prototype.match()

0
8Кб

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

Поиск
Категории
Больше
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...
От Leonard Pokrovski 2024-07-18 17:46:33 0 22Кб
Business
Best Interview Questions to Ask Candidates [and Great Interview Tips]
Hiring the right person for a role is critical to the success of any organization. While resumes...
От Dacey Rankins 2025-06-23 13:32:10 0 2Кб
Television
CGTN news (English) Live TV from China.
CGTN news, China Central Television (former CCTV 9) is a 24/7 news TV channel in the English...
От Nikolai Pokryshkin 2022-08-29 20:56:10 0 28Кб
Business
What Skills Do Successful Startup Founders Have?
Starting a business and leading a startup is no easy feat. The path to success is often filled...
От Dacey Rankins 2025-04-01 16:20:01 0 4Кб
Business
How can companies prepare for potential crises?
In an increasingly volatile world, companies face numerous risks that could disrupt their...
От Dacey Rankins 2025-01-17 16:51:24 0 10Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov