Regex to check with starts with http://, https:// or ftp://

You need a whole input match here.

System.out.println(test.matches("^(http|https|ftp)://.*$")); 

Edit:(Based on @davidchambers’s comment)

System.out.println(test.matches("^(https?|ftp)://.*$")); 

Leave a Comment