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

Suche
Kategorien
Mehr lesen
Employment
Recruitment agencies
A recruitment agency is an organization that professionally mediates between the applicant and...
Von FWhoop Xelqua 2023-03-16 18:42:47 0 25KB
Business
Advertising on billboards: how to attract attention and increase sales
Advertising on billboards: how to attract attention and increase salesAdvertising on billboards...
Von Dacey Rankins 2024-09-16 14:27:22 0 20KB
Economics
How Does Commercial Policy Affect the Economy?
How Does Commercial Policy Affect the Economy? Commercial policy is one of the most powerful...
Von Leonard Pokrovski 2026-02-23 14:54:09 0 9KB
Marketing and Advertising
Common Mistakes to Avoid in Video Marketing
Introduction Video marketing offers enormous potential, but it also comes with pitfalls that can...
Von Dacey Rankins 2025-11-13 17:22:40 0 35KB
Human Resources
What Is Onshoring vs Offshoring?
In global business strategy, companies must decide where to locate their operations. Two commonly...
Von Dacey Rankins 2026-04-01 21:26:31 0 2KB

BigMoney.VIP Powered by Hosting Pokrov