user2825425 user2825425 - 1 year ago 90
Python Question

Regular Expression to match "\\r"

I'm having trouble writing a regex that matches these inputs:




I need a regex that matches

Answer Source

Escape the back slashes twice. String's interpret \ as a special character marker.

Use \\\\r instead. \\ is actually interpreted as just \.

EDIT: So as per the comments you want any string that starts with \\r with any string after it. The regex pattern is as follows:


\\\\r is the string you want at the start and \S* says any non-white space (\S) can come after any number of times (*).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download