我有一个这样的字符串:
002_part1_part2 _______________ by_test
我希望在第二个下划线字符处停止匹配,如下所示:
002_part1_part2 _
如何使用正则表达式执行此操作?
由于
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以使用:
.*\d_
<强>说明强>
Match any single character that is NOT a line break character (line feed) «.*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match a single character that is a “digit” (any decimal number in any Unicode script) «\d»
Match the character “_” literally «_»