How to replace space with notepad ++ between two characters

I have a question how to replace space with _ using regex notepad ++ between characters []

Example:

sl.[Posting date]                       AS TIME, 
'0000-00-00'                            AS edate, 
sl.[Document No_], 
[Original Currency Factor]

Result

sl.[Posting_date]                       AS TIME, 
'0000-00-00'                            AS edate, 
sl.[Document_No_], 
[Original_Currency_Factor]
+5
source share
2 answers

Find what: [.+(\s)+.+]

Replaced by: _

Also do not forget to select the switch Regular expressionin the section Search mode.

Update:

Ok, I have one solution, but it's dirty:

To do this, you need to make several replacements.

Find what: (\[.*)\s(.*\])

Replaced by: \1_\2

Repeat with Replace alluntil there are no occurrences.

+16
source

Using

Regex Replacement

(\[[^ ]*) +(.*\])

with

$1_$2

if you want to replace multiple space characters with one _ OR

Regex Replacement

(\[[^ ]*) (.*\])

with

$1_$2

if you want to replace each space with one single _

0
source

All Articles