Select 正则表达式中的部分行

Select part of line in regular expression

I have this string:

#1#http://test.ir:8080/srvSC.svc#1#
#2#http://test.ir:8081/srvSC.svc#2#
#3#http://test.ir:8082/srvSC.svc#3#
#4#http://test.ir:8083/srvSC.svc#4#
#5#http://test.ir:8084/srvSC.svc#5#
#6#http://test.ir:8085/srvSC.svc#6#

我想 select 所有 #1# #2# ... 所以为了我写了这个表达式:^(^\#.\#) 但它只是 select 首先 line.How 我可以 select 第一个 #.# 和最后一个 #.#?

您可以使用

^(#\d+#)(.+)$

这将捕获组中的前 #s,重复任何字符,然后匹配在第一组中匹配的相同字符。您想要的字符串将在第二个捕获组中。

https://regex101.com/r/7Er0Ch/5