String.prototype.match()

0
12KB

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

Pesquisar
Categorias
Leia mais
Business
Why Do I Want to Start a Business?
Starting a business is a big decision—one that involves time, effort, and often a...
Por Dacey Rankins 2025-02-05 15:53:48 0 11KB
Business
Why Is Prospecting Important in Sales?
Prospecting is the foundation of every successful sales operation. Whether you’re an SDR...
Por Dacey Rankins 2025-12-09 18:22:05 0 5KB
Finance
What is a Pip, Point, and Spread in Forex?
What is a Pip, Point, and Spread in Forex? The foreign exchange (Forex) market is one of the...
Por Leonard Pokrovski 2025-10-15 11:05:11 0 4KB
Business
How to Give Feedback Effectively – Frameworks, Real-World Examples, and Best Practices
Giving feedback is a powerful skill—whether you're a manager, colleague, teacher, or peer....
Por Dacey Rankins 2025-07-30 11:32:58 0 7KB
Human Resources
What is Workplace Compliance?
In any organization, maintaining order, fairness, and legality is essential for long-term...
Por Dacey Rankins 2026-03-22 14:37:15 0 1KB

BigMoney.VIP Powered by Hosting Pokrov