[plug] regex

David Buddrige buddrige at wasp.net.au
Thu Mar 25 14:36:18 WST 2004


Hi all, 

I am wanting to write a short regex that will allow me to strip out extra 
spaces between words in an input stream. 

The program I have thus far is this:
#!/usr/bin/perl 

while(<>)
{
   $_ =~ s/\s{2,10}/ /g;
   print;
} 

which will replace between 2 and 10 spaces with a single space.  However, I 
want it to be an arbritarily large maximum limit - not simply 10 spaces.  
Does anyone know what I should use as the second parameter between the {} 
braces so that the regex will match 2 or more spaces?  I've been trawling 
through the manuals I have available but so far with no luck. 

thanks heaps guys 

David. 8-)



More information about the plug mailing list