http://someurlhere.com|http://sometexturl.com|sometexthere
Run Code Online (Sandbox Code Playgroud)
我想只提取在|之前的第一个网址 ,http://someurlhere.com
我写了正则表达式
\bhttp(.*)\|\b
Run Code Online (Sandbox Code Playgroud)
但它捕获了所有出现的
Thanx帮助表示赞赏
做出不同.*意见:.*?
\bhttp(.*?)\|\b
Run Code Online (Sandbox Code Playgroud)
如果你想在第一次之后匹配|:
\|http://(.*?)\|
Run Code Online (Sandbox Code Playgroud)
有了这个,网址就在 $1