1

Why is this simple regex not matching a carriage return? For reference, my data is the result of a SQL query and I have replaced linefeed \n with a single space.

\r

SRUS55 KSLC 082010\r\r HMTSLC\r\r 
klex52s
  • 437
  • 1
  • 7
  • 19
  • 3
    `\\r` will do that. But there is no CR, there is a combination of ``\`` and `r` chars in your example. BTW, you cannot input a CR in regex101.com, it only supports LF line endings. I suggest providing an example in Python. Please share an exact snippet to test your problem. – Wiktor Stribiżew Apr 18 '19 at 13:11

1 Answers1

2

There is no \r in your demo.

This is a newline character, either you were looking for \\r or [\n\r]+ if your string happens to include newlines.

For a more in-depth answer, see this explanation.

Jan
  • 42,290
  • 8
  • 54
  • 79