开发者

Why does this regex not match this text?

开发者 https://www.devze.com 2023-03-14 01:36 出处:网络
Why does the following regular expression not match this text? Text: Der Prozess kann nicht auf die Datei \"C:\\TEMP\\ExchToPlanSyncAppointments.log\" zugreifen, da sie von einem anderen Prozess verw

Why does the following regular expression not match this text?

Text: Der Prozess kann nicht auf die Datei "C:\TEMP\ExchToPlanSyncAppointments.log" zugreifen, da sie von einem anderen Prozess verwendet wird.
regex: Der Prozess kann nicht auf die Datei "([\w\s[:punct:]]+)" zugreifen, da sie von einem anderen 开发者_开发百科Prozess verwendet wird.


In C# regexes, [:punct:] is not interpreted as something special, so you are defining a character range that includes ':' and the letters in "punct".

Try ([\w\s:\.\\]+) instead.


See M42's, or use an @, as in string meh_regex = @"\w\w\w";.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号