removing duplicate spaces from a string

Ron Johnson ron.l.johnson at home.com
Mon Aug 6 16:16:12 EDT 2001


Hi, Richard.

Thanks you.

How efficient is Python on VMS?  Also, how useful is it as a
"super-DCL"?  Or does the lack of F$GETSYI, F$GETDVI, etc limit
it's usefulness?

Sincerely,
Ron

Richard Brodie wrote:
> 
> "Ron Johnson" <ron.l.johnson at home.com> wrote in message
> news:lvsb7.57979$oh1.21803460 at news2.rdc2.tx.home.com...
> 
>> Are there any builtins that will allow me to compress the
>> duplicate spaces out
> 
> You can use regular expressions (in the re module).  They can soon get
> complex but they don't start a lot easier than this.
> 
> $ python
> Python 1.5.2 (V007, Mon Jun  4 20:11:16 2001) [DECC] on OpenVMS Alpha
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> portions Copyright 1996-2000 Uwe Zessin
>>>> import re
>>>> whitespace = re.compile('\s+')
>>>> re.sub(whitespace, ' ', 'foo   bar      snafu')
> 'foo bar snafu'
> 
>> For anyone with VMS experience, I want to emulate the DCL lexical
>> function F$EDIT("COMPRESS").
> 
> Strictly , you would need an expression [ \t]+ :
> "match characters from the set (space or tab) one or more times".




More information about the Python-list mailing list