Page 1 of 1

Remove blank spaces between numbers

Posted: Mon Mar 17, 2014 11:47 am
by Shades
Hi,

I have a couple of text files that contain transcripts from conversations, text and numbers. In some files, the numbers have a blank space between them.
For example:

We will come in on Saturday to upgrade 2 8 servers. Those are the last machines on the list, so we'll have completed all 1 3 4 servers.

In that example, I'd need to find the 2 8 and the 1 3 4 and remove the space so the outcome is

We will come in on Saturday to upgrade 28 servers. Those are the last machines on the list, so we'll have completed all 134 servers.

I can find the text by searching for [0-9] [0-9] but I've not figured out what I would replace it with to remove the spaces. Plus I'm sure there's more intelligent ways to find the separator spaces between numbers.

Any help would be appreciated.

Re: Remove blank spaces between numbers

Posted: Wed Mar 19, 2014 3:03 pm
by DigitalVolcano
This example using lookahead works well in the tester:

regex:

Code: Select all

\b(\d+)\s+(?=\d+\b)
replace:

Code: Select all

$1
Disclaimer: I got it from here:
http://stackoverflow.com/questions/6929 ... tween-them