重写正则表达式而不是否定 [英] Rewrite regex without negation
问题描述
$ b
https::\ / \ /(()由于我使用的是golang / regexp lib,因此我们可以使用golang / regexp lib,我无法使用它,因为我的否定
(?!..
我想要什么要处理它,就是选择所有从http / https最后一次出现的文本直到结束。
sometextsometexhttp:/ /websites.com/path/subpath/#query1sometexthttp://websites.com/path/subpath/#query2
=>输出: http://websites.com/path/subpath/#query2
任何人都可以帮助我解决问题,我花了好几个小时尝试不同的方式来重现相同的结果,但没有成功。
https: :] * $
I have wrote this regex to help me extract some links from some text files:
https?:\/\/(?:.(?!https?:\/\/))+$
Because I am using golang/regexp lib, I'm not able to use it, due to my negation (?!..
What I would like to do with it, is to select all the text from the last occurance of http/https till the end.
sometextsometexhttp://websites.com/path/subpath/#query1sometexthttp://websites.com/path/subpath/#query2
=> Output: http://websites.com/path/subpath/#query2
Can anyone help me with a solution, I've spent several hours trying different ways of reproducing the same result with no success.
Try this regex:
https?:[^:]*$
这篇关于重写正则表达式而不是否定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!