What is a match JavaScript:- Geniusofstudent

  • 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:-

  1. <!DOCTYPE html> 
  2. <html> 
  3.  
  4. <head> 
  5.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  6. </head> 
  7.  
  8. <body> 
  9.  
  10.  <h1>match()</h1> 
  11.  
  12.  <input type="button" onclick="strfun();" value="Get Answer"> 
  13.  
  14.  <script> 
  15.   function strfun() 
  16.   { 
  17.    var str = "this is the far is the IS"; 
  18.    alert(str.match(/is/g)); //IS not matched 
  19.   } 
  20.  </script> 
  21.  
  22. </body> 
  23.  
  24. </html>
What is a match JavaScript:- Geniusofstudent What is a match JavaScript:- Geniusofstudent Reviewed by Network security on June 30, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.