String.prototype.match()

0
6K

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

Căutare
Categorii
Citeste mai mult
Business
Automation of the company's business processes
Automation of the company's business processesAutomation of business processes helps to save...
By Dacey Rankins 2024-09-23 16:34:20 0 12K
Programming
Python setup.py
setup.py is a python file, the presence of which is an indication that the module/package...
By Jesse Thomas 2023-04-26 21:12:26 0 6K
Programming
Python python-twitter-v2
python-twitter-v2 is a Twitter API wrapper used for accessing the endpoints easier with aiohttp....
By Jesse Thomas 2023-04-24 20:22:42 0 6K
Social Issues
Spare Parts. (2020)
While travelling on their first American tour, Ms. 45, an all-girl punk band, is drugged and...
By Leonard Pokrovski 2022-10-20 21:09:11 0 19K
Quotations
Quotes from great people
We all patiently count down the last days until spring arrives. But it is better to spend this...
By FWhoop Xelqua 2022-11-13 12:39:27 0 16K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov