Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用以下正则表达式来确定在某个标记之后找到的下一个单词:
(?<=marker:\W{1})(\w+)
如何更新它以确定标记后的下 8 个字符,包括空格或其他特殊字符,如-或/
-
/
谢谢,亚历克斯
源代码如下所示:
test : 1205 no.: abc marker: 12345678 something: xxx
我需要12345678
12345678
您可以使用.匹配“任何字符”;
.
(?<=marker:\W{1})(.{8})
在您的捕获组中使用.而不是\w使用另一个量词:
\w
(?<=marker:\W)(.{8})