- The match() method searches a string for a match against a regular expression, and returns the matches, as an Array object.
- If the regular expression does not include the g modifier (to perform a global search), the match() method will return only the first match in the string.
- This method returns null if no match is found.
Code:-
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>match()</h1>
- <input type="button" onclick="strfun();" value="Get Answer">
- <script>
- function strfun()
- {
- var str = "this is the far is the IS";
- alert(str.match(/is/g)); //IS not matched
- }
- </script>
- </body>
- </html>
What is a match JavaScript:- Geniusofstudent
Reviewed by Network security
on
June 30, 2019
Rating:
No comments: