On Mon, Nov 25, 2002 at 11:15:15AM +1300, Mark Carey wrote:
> Some of my lines of data do not have sufficient space between the
> previous column and the next column, e.g.

> 2.354647E10-0.56495E-9 0.6758E4
> Note the  ^^ missing space, now I was wondering if it was somehow
> possible to use a regexp to look for the pattern [0-9]-[0-9] and
> replace
> with [0-9] -[0-9], note the extra space.  This should not get tripped
> up
> on the E, if my understanding of regexp is correct.

Where $data contains data formatted like your example above, use:

$data =~ s/([0-9])(-[0-9])/$1 $2/g;

 - 's///' is the search and replace operator.
 - '$1' is replaced by what is matched in '([0-9])'
 - '$2' is replaced by what is matched in '(-[0-9])'
 - the trailing 'g' causes the search and replace to be global.

Cheers,
-mjg
-- 
Matthew Gregan                     |/
                                  /|                [EMAIL PROTECTED]

Reply via email to