1

I have written a program that searches for 'opens' without matching 'closes' in a target file. It produces an output like this:

open
close
open
open
close

In this example here the second 'open' is not immediately followed by a matching 'close', so I consider that an error. My text-editor (editpad) has a regular-expression search/replace feature, which I would like to use to get rid of all correct pairs, so I can notice easily the incorrect situations. I tried replacing the following

open\r\nclose

I thought that this would match the two words and the line-break between them (I'm using Windows). This did not work.

Does anyone have an idea why it didn't?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Mark Springer
  • 195
  • 1
  • 8

1 Answers1

1

If you select the Regex mode, your regex will work, but I also suggest making \r optional by appending ? after it to support LF endings, too:

open\r?\nclose

See the screenshot with settings and proof it works in EditPad:

enter image description here

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563