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
Business
How Long Should a Business Plan Be?
Searchers often want guidelines on the ideal length and depth of a business plan. Whether you're...
Von Dacey Rankins 2024-12-18 16:48:08 0 16KB
Marketing and Advertising
What Are the Advantages of Newspaper Advertising?
In a marketing world dominated by algorithms, dashboards, and digital noise, newspaper...
Von Dacey Rankins 2026-01-23 19:20:47 0 3KB
Business
How Do I Start Vlogging?
Introduction Vlogging — or video blogging — has evolved from a casual hobby into a...
Von Dacey Rankins 2025-11-11 18:14:39 0 6KB
Entertainment
Art and Entertainment: The Intersection of Creativity and Enjoyment
Art and entertainment have long been intertwined, forming a symbiotic relationship that enriches...
Von Dacey Rankins 2025-01-22 14:34:18 0 18KB
Regional
China as a global partner
The first series of broadcasts is dedicated to China. Alexey Kalinin, Vice-Rector for Research at...
Von FWhoop Xelqua 2023-07-22 18:10:41 0 34KB

BigMoney.VIP Powered by Hosting Pokrov