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 Do I Adapt My Communication for Different Audiences or Situations?
Introduction Effective communication is not a “one-size-fits-all” skill. The way we...
Von Dacey Rankins 2025-11-20 15:18:54 0 2KB
Business
How Long Do Coaching Engagements Last?
Coaching is a personalized process designed to help individuals grow, gain clarity, and achieve...
Von Dacey Rankins 2025-07-22 11:00:05 0 7KB
Finance
How Fintech Is Transforming the Finance Industry and Global Economy
How Fintech Is Transforming the Finance Industry and Global Economy Financial...
Von Leonard Pokrovski 2025-10-13 17:00:46 0 5KB
Internet
Windows OS will be transferred to the "cloud"
Microsoft has planned to completely transfer the Windows operating system (OS) to the "cloud"...
Von FWhoop Xelqua 2023-06-28 18:03:35 0 24KB
Marketing and Advertising
How Often Should I Post Vlogs, and How Long Should They Be?
Introduction Once you’ve found your niche and started creating content, the next big...
Von Dacey Rankins 2025-11-11 18:44:03 0 4KB

BigMoney.VIP Powered by Hosting Pokrov