PHP:另一个我无法弄清楚的正则表达式


PHP: Another regex I can't figure out

我在PHP中使用2个正则表达式时遇到问题

1. 剥离 http(s)://和 www.

https://www.google.be/search?sclient=psy-ab&q=regex&oq=regex
http://www.google.be/search?sclient=psy-ab&q=regex&oq=regex
https://google.be/search?sclient=psy-ab&q=regex&oq=regex
http://google.be/search?sclient=psy-ab&q=regex&oq=regex
=> google.be/search?sclient=psy-ab&q=regex&oq=regex

2. 3-30个字符,可以包含a-zA-Z0-9.-_*,但至少需要一个字母或数字

Valid: -_l*96d.*
Invalid: *-_.

我已经搜索了这么久没有任何结果,所以请帮忙!

非常感谢!

    preg_replace('/^(http|https):'/'/(www'.)?/i', '', $url)

第二个正则表达式如下所示:

'/^(?=[0-9a-zA-Z])[a-zA-Z0-9'-'*_'.]{3,30)$/'