擅长:python、mysql、java
<p>它认为最好在这里使用<a href="https://docs.python.org/3/library/re.html#re.match" rel="nofollow">^{<cd1>}</a>和稍微不同的模式:</p>
<pre><code>>>> import re
>>> link = "http://google.com/whatever/who/jx.html"
>>> re.match("(https?://.+?)(/.*$)", link).groups()
('http://google.com', '/whatever/who/jx.html')
>>>
</code></pre>
<p>下面是上面使用的正则表达式模式匹配的细分:</p>
<pre><code>( # The start of the first capture group
http # http
s? # An optional s
:// # ://
.+? # One or more characters matched non-greedily
) # The close of the first capture group
( # The start of the second capture group
/ # /
.* # Zero or more characters
$ # The end of the string
) # The close of the second capture group
</code></pre>