Replacing variable number of blanks?
Posted: Sat Sep 28, 2013 6:40 am
How would I change a list with entries like this
into this please:
United Kingdom: 2.75
Norway: 3.4
Palestinian territories: 5.6
Saint Vincent and the Grenadines: 6.6
Germany: 6.7
I tried this:
Replace (.*)([ ]{1})([0-9])(.*)
with
\1:\3\4
But that gave lines like
So it seems that my {1} is not being interpreted as "1 or more instances of the preceding element" as I'd read somewhere.
How *do* you specify that then please?
It's obviously complicated by the need to distinguish blanks within the country name from those which need 'compacting'.
--
Terry, East Grinstead, UK
Code: Select all
United Kingdom 2.75
Norway 3.4
Palestinian territories 5.6
Saint Vincent and the Grenadines 6.6
Germany 6.7
United Kingdom: 2.75
Norway: 3.4
Palestinian territories: 5.6
Saint Vincent and the Grenadines: 6.6
Germany: 6.7
I tried this:
Replace (.*)([ ]{1})([0-9])(.*)
with
\1:\3\4
But that gave lines like
Code: Select all
United Kingdom :2.75How *do* you specify that then please?
It's obviously complicated by the need to distinguish blanks within the country name from those which need 'compacting'.
--
Terry, East Grinstead, UK