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
Initially, the Product Owner is Responsible for Capturing Stories, but the Team Can Capture Technical Stories and Spikes
In Agile development, user stories are the primary units of work, capturing functionality from...
Von Dacey Rankins 2025-08-26 12:28:48 0 9KB
Regional
Doctors create a database of DNA residents of New York: why is it necessary
This week, Mount Sinai Health System began work to create an extensive database of patients'...
Von FWhoop Xelqua 2023-02-14 17:57:45 0 27KB
Business
How Do I Speak Confidently in Front of Others?
Speaking confidently in front of others — whether it’s a class, a small group, or a...
Von Dacey Rankins 2025-12-10 17:40:47 0 2KB
Business
How Do You Set Sales Goals and Quotas?
Setting sales goals and quotas is one of the most critical responsibilities in sales management....
Von Dacey Rankins 2025-12-23 19:47:47 0 2KB
Business
What Are the Company's Core Values and Mission?
Every successful organization is built on a foundation of purpose and guiding principles. A...
Von Dacey Rankins 2025-08-05 15:08:35 0 6KB

BigMoney.VIP Powered by Hosting Pokrov