我正在搜索匹配上一个\
和_
示例:
输入:\\\ezbe.local\folder1\folder2\folder3\33248a-48596-a54qsd-4d7d98_2
输出:33248a-48596-a54qsd-4d7d98
答案 0 :(得分: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