String.prototype.match()

0
11K

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

Site içinde arama yapın
Kategoriler
Read More
Finance
Which Finance Biography Books Are More Suitable for Beginners vs. More Advanced Readers?
Which Finance Biography Books Are More Suitable for Beginners vs. More Advanced Readers? Finance...
By Leonard Pokrovski 2025-10-08 20:56:28 0 5K
Business
What Are the Best Tools for Startup Founders?
Starting a new business can be both exciting and overwhelming. As a startup founder, you'll wear...
By Dacey Rankins 2025-04-04 14:15:30 0 13K
Business
How to Write a Business Plan for a Small Business: A Step-by-Step Guide
Writing a business plan is an essential step for any small business owner looking to formalize...
By Dacey Rankins 2024-12-23 15:59:47 0 12K
Humor
The Evolution of Humor Over the Years: A Journey Through Time and Culture
Humor, an intrinsic part of human nature, has evolved significantly over the centuries. From...
By Dacey Rankins 2024-12-03 15:29:07 0 14K
Programming
Golang vs Java
Golang  Launched in 2011, Go or Golang is an open-source language from Google. Similar...
By Jesse Thomas 2023-07-03 17:15:47 0 13K

BigMoney.VIP Powered by Hosting Pokrov