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

后端 未结 5 1900
一个人的身影
一个人的身影 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

    If you wanna do it in case-insensitive way, this is better:

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

提交回复
热议问题