String.prototype.match()

0
12K

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
Искусство, культура и развлечения
Тайна Коко. Coco. (2017)
12-летний Мигель живёт в мексиканской деревушке в семье сапожников и тайно мечтает стать...
Por Nikolai Pokryshkin 2022-12-29 13:00:25 1 28K
Investing
The Pros and Cons of Investing: Weighing Your Options
Investing is a powerful tool for building wealth and achieving financial goals. However, it comes...
Por Dacey Rankins 2024-10-09 17:31:39 0 19K
Business
How Do Competitors Engage With Customers?
In any market, customer engagement is one of the most important factors that determines whether...
Por Dacey Rankins 2025-09-29 20:10:20 0 7K
Business
How to Pitch Your Business Plan to Investors: A Comprehensive Guide
Pitching your business plan to investors is one of the most critical steps in securing funding...
Por Dacey Rankins 2024-12-23 15:58:07 0 22K
Business
How Can I Get My First Customers?
Getting your first customers is one of the biggest challenges when starting a business. Without a...
Por Dacey Rankins 2025-03-14 16:16:11 0 14K

BigMoney.VIP Powered by Hosting Pokrov