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

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Financial Services
Explicit and implicit costs and accounting and economic profit
Key points Privately owned firms are motivated to earn profits. Profit is the...
από Mark Lorenzo 2023-04-24 18:42:05 0 14χλμ.
Business
How Does Intrapreneurship Differ from Entrepreneurship?
In today’s fast-paced and innovation-driven world, both entrepreneurship and...
από Dacey Rankins 2025-04-17 12:47:02 0 9χλμ.
Nutrition
How to eat healthy
Proper, healthy nutrition does not mean a boring menu and giving up delicious dishes. Just the...
από Dacey Rankins 2024-04-19 20:13:24 0 17χλμ.
Conditions and Diseases
Common Conditions and Diseases Found in Children: A Guide for Parents and Caregivers
Children are at a unique stage of development where their bodies and...
από Dacey Rankins 2024-12-10 14:07:07 0 11χλμ.
Научная фантастика и фэнтези
Твоё имя. Your Name. (2016)
Токийский парень Таки и провинциальная девушка Мицуха обнаруживают, что между ними существует...
από Nikolai Pokryshkin 2023-01-06 12:51:53 0 24χλμ.

BigMoney.VIP Powered by Hosting Pokrov