Reputation: 6615
Trying to do this in the Atom editor (1.39.1 x64, uBuntu 18.04), though assume this applies to other text editors using regular expressions.
Say we have this text:
This text has some double-spaces. Lets try to remove them.
But not after a full-stop or if three or more spaces.
Which we would like to change to:
This text has some double-spaces. Lets try to remove them.
But not after a full-stop or if three or more spaces.
Using Find with Regex
enabled (.*
), all occurrences are correctly found using: [a-zA-Z] [a-zA-Z]
. But what goes in the Replace
row to enforce the logic:
1st letter, single space, 2nd letter?
Upvotes: 1
Views: 544
Reputation: 37745
You can use this
([a-z])\s{2}([a-z])
and replace by $1 $2
If your editor supports lookarounds you can use
(?<=[a-z])\s{2}(?=[a-z])
Replace by single space character
Note:- don't forget to use i
flag for case insensitivity or just change the character class to [a-zA-Z]
Upvotes: 2