擅长:python、mysql、java
<p>您可以这样使用正则表达式:</p>
<pre><code>(.+?)(http.*)?$
</code></pre>
<p><strong><a href="https://regex101.com/r/eS4nV4/1" rel="nofollow noreferrer">Working demo</a></strong></p>
<p><img src="https://i.stack.imgur.com/2nnTG.png" alt="enter image description here"/></p>
<p>如您所见,在以下情况下,没有完全实现您的目标:</p>
<pre><code>some text - http://a.link.to/something
</code></pre>
<p>因为它产生:</p>
<pre><code>{'text': 'some text - ', 'link': 'http://a.link.to/something'}
^ - Dash here
</code></pre>
<p>但是你可以对文本进行前清理或后清理</p>
<p>我把答案贴出来是因为它可能对你有帮助</p>