Regex URL Match

后端 未结 3 1336
滥情空心
滥情空心 2021-01-29 07:43

I just really started learning how to use regex\'s and i am trying to create one to match urls. So far i have:

(http://|https://|www|\\w)+\\.[\\w]{2,4}[^\\s]+
         


        
3条回答
  •  自闭症患者
    2021-01-29 08:03

    Give this one a try: ^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$ Note that depending on how you are using it, you might want to remove the ^ and $ from the beginning and end.

提交回复
热议问题