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

后端 未结 5 1910
一个人的身影
一个人的身影 2020-12-28 12:59

I am framing a regex to check if a word starts with http:// or https:// or ftp://, my code is as follows,

     public          


        
5条回答
  •  没有蜡笔的小新
    2020-12-28 13:20

    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)://.*$")); 
    

提交回复
热议问题