快速提问: 我有一个 regexp,^(?:\b[A-Z]+\b\s+)+(.*)\d{8},它提供了两个捕获组。我想用空格替换捕获组1。这可能吗?
^(?:\b[A-Z]+\b\s+)+(.*)\d{8}
如果我用: \1替换,它用 Hello, world. Another word here替换 TEST TESTER Hello, world. Another word here. 75793250-> 。我想要这个结果: TEST TESTER 75793250。用空格替换 \1。
\1
Hello, world. Another word here
TEST TESTER Hello, world. Another word here. 75793250
TEST TESTER 75793250
Do it this way:
Regex: ^(\b[A-Z]+\b\s+)+(?:.*)(\d{8})
^(\b[A-Z]+\b\s+)+(?:.*)(\d{8})
Replace with: \1 \2
\1 \2
Try using:
^((?:\b[A-Z]+\b\s+)+)(?:.*)(\d{8})
And replace with:
\1\2