I have a large text file with many extraneous newlines rn
. I wish to replace each of these immediately following a letter in the range a-z with that letter followed by a blank space. Using notepad++ the regex [a-z]rn
finds this combination all right, but I have not been able to determine the correct replacement expression. For example the file contains Indianrn
which I would like to replace with Indian
followed by a blank.
This has been done in the above description of my problem.
Example:
Copy the following text into notepad++:
He glanced at his watch another two hours to go.
He went over in his mind all that had appeared in the papers about
IndianIsland.
Hit ctrl H to bring up the replacement dialog.
In the lower left hand corner select regular expression.
Find what: [a-z]rn
Replace with: ([a-z])
Clicking on Find next results in highlighting of the final n
in Indian and the next two spaces
for the invisible carriage return and line feed. Clicking on Replace results in replacing the n
with [a-z]
and rn
with a blank.
I thought placing parentheses around [a-z]
would back reference the letter particular letter n
found, and yield simply n
followed by a blank.
Note: There is an invisible blank after ([a-z])
in the Replace with: box.
Note: Since there is a period and not a letter preceding the rn
in the first line, this is skipped over.
rko15 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Find: ([a-z])rn
and Replace with: $1
. The $1
in the replacement expression represents your first captured group. You can also use 1
if you are familiar with this usage from other regex flavors.
The documentation gets a little complex but here is a link to the relevant page: npp-user-manual#regular-expressions.