JavaScript, match() Method

The match(), Method from JavaScript it's used to find a match between a String or Regular Expression and a String and returns the matches, (could be an array or just one match, depending on the given instructions and the content of the string), or null if none it's found. In the example below, you'll see a practical application of this Method.

Syntax:
string.match(/RegExp/ or "String")

See the example below.









<script type='text/javascript'>
var h='Who do you LOVE more?'

document.write(h.match(/o/gi))
</script>



In this Script the the match() method returns the an array of "o" letter.