String.prototype.match()

0
11KB

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

Suche
Kategorien
Mehr lesen
Social Issues
Thirteen. (2003)
A thirteen-year-old girl's relationship with her mother is put to the test as she discovers...
Von Leonard Pokrovski 2023-04-28 19:32:50 0 27KB
Chemistry
Chemistry: The Science and Art of Matter
Chemistry plays a central role both due to its place among the natural and cognitive sciences,...
Von FWhoop Xelqua 2023-03-21 16:32:17 0 24KB
Business
Which forecasting method is best for my business?
In today’s dynamic business environment, forecasting is crucial for effective planning and...
Von Dacey Rankins 2025-01-10 14:05:47 0 12KB
Personal Finance
What Is FAFSA and How Do I Complete It?
What Is FAFSA and How Do I Complete It? Paying for college or career school can feel...
Von Leonard Pokrovski 2025-12-15 18:40:46 0 1KB
Business
Is Entrepreneurship Worth It in 2025?
Entrepreneurship has long been seen as a path to freedom, creativity, and financial success. But...
Von Dacey Rankins 2025-03-18 13:56:31 0 9KB

BigMoney.VIP Powered by Hosting Pokrov