Golang - extract links using regex
我需要得到所有的文本链接,在特定的域example.de
使用正则表达式在围棋
以下是应提取的所有可能链接:
https://example.de
https://example.de/
https://example.de/home
https://example.de/home/
https://example.de/home some text that should not be extracted
https://abc.example.de
https://abc.example.de/
https://abc.example.de/home
https://abc.example.de/home
https://abc.example.de/home some text that should not be extracted
我已经试过了
我用这个网站判断我的正则表达式是否正确:https://regex101.com/r/ohxUcG/2
-
https?://*.+example.de*.+
在表达式https://abc.example.de/a1b2c3 dsadsa
中无法将整个文本发送到\n
,而不是没有dsadsa
的https://abc.example.de/a1b2c3
-
https?://*.+example.de*.+\s(\w+)$
这会得到只以空间终止的链接,但有时链接可以以\n
或\t
等终止.