Coddy
Coddy

Reputation: 891

How to remove a space between two characters or strings in notepad++

Consider I have a string in quotations "( the" which occures in a huge body of text.

I want to remove the space between non-alphanumeric ( and aplphanumeric t characters

Upvotes: 4

Views: 16080

Answers (3)

Ωmega
Ωmega

Reputation: 43673

Replace match of regular expression pattern (?<=\()\s+(?=t) with empty string.

Regular expression visualization

If any alphanumeric character may occur after such space, then use pattern (?<=\()\s+(?=[^\W_])

Regular expression visualization

Upvotes: 6

thesquaregroot
thesquaregroot

Reputation: 1452

Per this answer if you are using version 6.0 or later you can use Perl compatible regular expressions. So you could do the following regex search and replace.

replace (\W) (\w) with \1\2
replace (\w) (\W) with \1\2

This will remove the space between any non-alphanumeric and alphnumeric characters first, then the reverse (alnum, space, non-alnum).

Upvotes: 1

MarcinJuraszek
MarcinJuraszek

Reputation: 125630

Following regex find/replace will do it for all, not only ( t occurrences:

Find: \( ([a-zA-Z])

Replace: \(\1

Remember to check Regular expression on the bottom of the dialog.

Upvotes: 0

Related Questions