Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace whitespace with notepad++ between two characters

I have question how to replace whitespace with _ using notepad++ regex 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]
like image 211
Justin Avatar asked Mar 14 '12 14:03

Justin


People also ask

How do I get rid of extra space between words in notepad?

Here a workaround that work on most of the software : Open the "Search and Replace" function (CTRL+H), in the "Search" field type two space " " and in the "Replace" field type one space " " then click on "Replace All" button as many time as you need to replace all the useless space (0 occurrences found).

How do I add a space between text in Notepad?

To add a space in a text editor, move the cursor to the place where you want to add the space, using either the arrow keys on your keyboard or by clicking there with your mouse, then press the space bar in your keyboard.

How do I replace multiple characters in Notepad++?

In Notepad++ press Ctr+H to open the “Find and Replace” window. Under Search Mode: choose “Regular expression” and then check the “matches newline” checkbox. You should see closing </p> tags at the end of each line.


1 Answers

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

Replace with: _

Also don't forget to select Regular expression radio button in Search mode section.

Update:

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

You need to perform several replacements to do that.

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

Replace with: \1_\2

Repeat using Replace all until there will be no occurrences.

like image 91
antyrat Avatar answered Sep 21 '22 07:09

antyrat