I am framing a regex to check if a word starts with http:// or https:// or ftp://, my code is as follows,
http://
https://
ftp://
public
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)://.*$"));