match url pattern in php using regular expression

前端 未结 8 1701
别那么骄傲
别那么骄傲 2020-12-01 18:32

I want to match a url link in wall post and replace this link with anchor tag, for this I use the regular expression below.

I would like the match 4 types of url:

8条回答
  •  心在旅途
    2020-12-01 19:14

    use this pattern .

    $regex = "(https?\:\/\/|ftp\:\/\/|www\.|[a-z0-9-]+)+([a-z0-9-]+)\.+([a-z]{2,4})((\/|\.)+([a-z0-9-_.\/]*)$|$)";
    

提交回复
热议问题