Find and Replace with RegEx

Dear Experts,

I tried to use Find and Replace with RegEx in a document to remove unwanted line returns.


Desired result:

The goal is to remove returns before those lines starting with a small letter. Following the manual, in the Find field I inputed “\R[a-z]” and in the Replace field I inputed “$1”. The result became:

Presumably the variable $1 was empty.
Would you know any methods to do this? Thanks very much!


In RegEx, the $1 is a backreference that matches your first capture group–but in the expression you have, there is no capture group, so when you use this in the replace with field, it’s empty. Since you want this to put back the lowercase letter in the search, you’ll want to place the [a-z] inside parentheses, like so:


A couple of further notes:

  • \R will replace both regular “hard” carriage returns and soft returns. If you’re only trying to replace the former, you can use \n instead.
  • Be sure you have “Ignore Case” deselected, or [a-z] will also match [A-Z]

Dear MimeticMouton,

Thank you very much for your prompt reply sharing your expertise, which saves a ton of my time.
I just couldn’t find in the manual about the parentheses expression.

Best regards,