PHP regex match all urls -


this question has answer here:

i need creating regex match urls example, please not close question duplicate have been looking need long time, , none of answers have seen have given answer solves problem.

website.com

www.website.com

http://www.website.com

http://website.com

https://www.website.com

https://website.com

with trailing

www.website.com/path-to-something

i coding shortens url, so, first need match them all.

thanks

this 1 match correctly posted:

preg_match_all('#[-a-za-z0-9@:%_\+.~\#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-za-z0-9@:%_\+.~\#?&//=]*)?#si', $targetstring, $result); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -