Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

regex

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

like image 957
Coddy Avatar asked Sep 15 '25 06:09

Coddy


2 Answers

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

like image 109
Ωmega Avatar answered Sep 17 '25 04:09

Ωmega


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).

like image 45
thesquaregroot Avatar answered Sep 17 '25 03:09

thesquaregroot