JavaScript String match() Method

You are Here:

JavaScript String match() Method

The match() method retrieves the result of matching a string against a regular expression, as an Array object.


HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var str = "the end will never end"; var regex = /end/g; var result = str.match(regex); document.write(result); </script> </body> </html>



Parameter Values

regexpRequiredA regular expression object which represents the value to search for.
If omitted you will get an Array with an empty string: [""].

Return Value

[array]If the string matches the expression, it will return an Array containing the entire matched string.
nullIf no match is found.


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author