Use RegEx to get end of string - Javascript String Operation

Javascript examples for String Operation:String Search

Description

Use RegEx to get end of string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from   w w  w. ja v a 2s  .  co  m
var patternURL = new RegExp("http(s)?://www\.java2s\.com(/|/\\?ref=(tn_tnmn|logo)+)?$", "m");
var targetURL = "https://www.java2s.com/messages";
console.log (patternURL.test("https://www.java2s.com/?ref=tn_tnmn"));
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials