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

Pesquisar
Categorias
Leia Mais
Wholesale Trade
Understanding Wholesale Trade: Key Insights and Its Role in the Economy
Wholesale trade is a fundamental part of the global supply chain and plays a pivotal role in the...
Por Dacey Rankins 2024-11-25 14:14:38 0 12K
Graphics
Neural networks for the designer: the best services with AI to simplify the work
Neural networks are a powerful tool that can help designers improve the efficiency and quality of...
Por FWhoop Xelqua 2023-06-15 20:11:05 0 31K
Mental Health
Dyslexia: Causes
Researchers have been trying to find the neurobiological basis of dyslexia since the condition...
Por Kelsey Rodriguez 2023-06-19 17:58:22 0 11K
Programming
Python __init__.py
Python defines two types of packages, regular packages and namespace packages. Regular packages...
Por Jesse Thomas 2023-03-16 21:48:31 0 11K
Научная фантастика и фэнтези
Властелин колец: Две крепости. The Lord of the Rings: The Two Towers. (2002)
Братство распалось, но Кольцо Всевластья должно быть уничтожено. Фродо и Сэм вынуждены довериться...
Por Nikolai Pokryshkin 2022-11-10 10:38:15 0 38K

BigMoney.VIP Powered by Hosting Pokrov