PHP regular intercepts the content after the domain name in the URL
phpcn_u15822017-05-16 13:14:30
0
5
1051
php program needs to match the beginning of http:// or https://, retain the domain name, and intercept the content after the domain name For example, http://www.baidu.com/aa/bbb only needs http ://www.baidu.com intercept /aa/bbb
You don’t have to use regular rules to be generous. Isn’t this more elegant?
If possible, try not to use regular expressions
There are many methods for this. Since the requirement is regular, please see the code below
https://www.bytelang.com/o/s/...
Refer to the answers below
Isn’t it better to use explode? Why use regular expressions