擅长:python、mysql、java
<p>你可以用</p>
<pre><code>^(?:(?:https?|ftps?|gopher|telnet):\/\/|www\.|mailto:)\S+
</code></pre>
<p>见<a href="https://regex101.com/r/FRzGBJ/9" rel="nofollow noreferrer">regex demo</a>和<a href="https://jex.im/regulex/#!flags=&re=%5E(%3F%3A(%3F%3Ahttps%3F%7Cftps%3F%7Cgopher%7Ctelnet)%3A%5C%2F%5C%2F%7Cwww%5C.%7Cmailto%3A)%5CS%2B" rel="nofollow noreferrer">its graph</a>:</p>
<p><a href="https://i.stack.imgur.com/RVGGR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RVGGR.png" alt="enter image description here"/></a></p>
<p><strong>详细信息</strong></p>
<ul>
<li><code>^</code>-字符串的开头</li>
<li><code>(?:(?:https?|ftps?|gopher|telnet):\/\/|www\.|mailto:)</code>-任何一种
<ul>
<li><code>(?:https?|ftps?|gopher|telnet):\/\/</code>-<code>http</code>、<code>https</code>、<code>ftp</code>、<code>ftps</code>、<code>gopher</code>或<code>telnet</code>然后<code>://</code>子串</li>
<li><code>|</code>-或</li>
<li><code>www\.</code>-<code>www.</code>子串</li>
<li><code>|</code>-或</li>
<li><code>mailto:</code>-<code>mailto:</code>子串</li>
</ul></li>
<li><code>\S+</code>-1个或多个非空白字符</李>
</ul>