How To Use String Object Match In Java Script
In this article I am going to explain about String Object Match In JavaScript.
Use match() method in JavaScript
The match() method search an string value from a array object.
This method count the match value and print it.
All browsers support string object match() method.
Syntax
Example
<!DOCTYPE html>
<html>
<body style ="background-color:Red">
<p id="demo">Display the matches.</p>
<button onclick="myFunction()">Click here</button>
<script type="text/javascript">
function myFunction() {
var str = "The rain in SPAIN stays mainly in the plain";
var n = str.match(/ain/g);
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
|
Output1

Output2

Further Readings
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here