我需要在格式中匹配子字符串
!some text!https://test.com/
两个之间的任何东西
!
标记是文本,后面是没有空格的url,
到目前为止,我做了一个正则表达式,可以找到子串
(!(.*)!((https|http):\/\/[^\s+]))
例如
!text goes here!https://amazon.com and some other text comes here
应该解析
!text goes here!https://amazon.com
它做得很好,但是当我在文本的任何地方复制这种模式时,它会匹配两个文本之间的整个文本。
即
!text goes here!https://amazon.com some text here !text goes here!https://amazon.com and after some other text
应该是两个分开的
!text goes here!https://amazon.com some
但它会选择子串直到第二次匹配结束
!text goes here!https://amazon.com some text here !text goes here!https://amazon.com
也许这需要整个文本
!
最后呢
!
当url文本后遇到空格时,是否有停止匹配的方法