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
What Challenges Did the CEO Face in Their Career?
Every CEO, no matter how successful, has faced significant challenges on the road to the top....
Von Dacey Rankins 2025-06-30 14:05:33 0 7KB
Business
How Do I Make Meetings More Engaging?
Moving Beyond Monologues to Meaningful Interaction Let’s face it—many meetings are...
Von Dacey Rankins 2025-07-31 16:55:03 0 7KB
Business
What Do You Like Most About Working for This Company?
During a job interview, one insightful question candidates often ask is: "What do you like most...
Von Dacey Rankins 2025-06-24 15:31:26 0 6KB
Жизненные вопросы
Золотая лихорадка. The Gold Rush. (1925)
История о злоключениях извечного любимца публики, маленького бродяги, который на этот раз...
Von Nikolai Pokryshkin 2023-03-17 15:22:14 0 23KB
Personal Finance
What Other Costs Come With Taking Out a Mortgage?
What Other Costs Come With Taking Out a Mortgage? For many people, buying a home is the largest...
Von Leonard Pokrovski 2025-11-14 21:39:08 0 2KB

BigMoney.VIP Powered by Hosting Pokrov