2

我正在搜索与最后一个之间的值匹配的正则表达式\_

例子:

输入\\\ezbe.local\folder1\folder2\folder3\33248a-48596-a54qsd-4d7d98_2

输出33248a-48596-a54qsd-4d7d98

4

1 回答 1

5

那将是

[^\\]*(?=_[^\\]*$)

解释:

[^\\]*   # Match any number of non-backslash characters
(?=      # if the following is true after the matched text:
 _       # There is a _
 [^\\]*  # followed only by non-backslash characters
 $       # until the end of the string.
)        # End of lookahead assertion
于 2013-05-26T12:22:56.327 回答