title: Regex to check with starts with http://, https:// or ftp://
body: <p>I am framing a regex to check if a word starts with <code>http://</code> or <code>https://</code> or <code>ftp://</code>, my code is as follows,</p>
  
  <pre><code>     public static void main(String[] args) {
      try{
          String test = "http://yahoo.com";
          System.out.println(test.matches("^(http|https|ftp)://"));
      } finally{
  
      }
  }
  </code></pre>
  
  <p>It prints <code>false</code>. I also checked stackoverflow post <a href="https://stackoverflow.com/questions/4643142/regex-to-test-if-string-begins-with-http-or-https">Regex to test if string begins with http:// or https://</a></p>
  
  <p>The regex seems to be right but why is it not matching?. I even tried <code>^(http|https|ftp)\://</code> and <code>^(http|https|ftp)\\://</code></p>