String.prototype.match()

0
11Кб

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

Поиск
Категории
Больше
Environment
The 10 most environmentally friendly countries
The site for expats InterNations interviewed about 15 thousand people who left their home...
От FWhoop Xelqua 2022-12-24 15:35:08 0 21Кб
Play Groups
Collection of games
Team-Building Compilation CATERPILLARThe team stands in a single line, facing to...
От Leonard Pokrovski 2024-04-05 21:32:03 0 25Кб
Business
Who Supports Me? Am I Setting Healthy Boundaries?
Life is not a solo journey. No matter how independent we are, our growth and happiness are shaped...
От Dacey Rankins 2025-09-08 08:08:04 0 4Кб
Business
How to Drive Ecommerce Growth Through Conversion Rate Optimization
How to Drive Ecommerce Growth Through Conversion Rate Optimization Think of your...
От Leonard Pokrovski 2024-08-27 16:03:40 0 30Кб
Business
What are the best practices for responding to comments and feedback?
In today’s digital world, engaging with your audience through comments and feedback is more...
От Dacey Rankins 2025-02-20 16:51:59 0 10Кб

BigMoney.VIP Powered by Hosting Pokrov