Re: parsing [one more]

From: Tim Woodcock (twoodcock@baremetal.com)
Date: Sun Apr 06 2003 - 16:32:29 EDT


To be strictly correct, we more in the regex.

If I request "my domain.com" I do not expect to end up with mydomain.com.
Sure the space is invalid, but it is an error, and should be diagnosed as
an error.

What you are looking for is this: s/^\s+|\s+$//g

Message received 2003-04-06 from 'Bernd Hilmar':

> On Sun, 2003-04-06 at 06:21, Richard Jones wrote:
> > Sorry, one more...
> > I forgot to have it strip out whitespaces...
> > Here you go...
> >
> > $domain =~ s/^www\.//i; # Kill www. - AFTER THIS LINE add this
> > one:
> > $domain =~ s/ //i; # Kill the blank spaces (whitespace)
>
> hello,
>
> you can remove whitespaces by doing like this:
>
> $domain =~ s/\s//g;
>
> Use "g" as modifier to find a pattern in a whole string.
> To find (and replace) whitespaces "i" as modifier is not
> necessary, because the "i" modifier is to _i_gnore the
> case of the pattern and a whitespace has no case.
>
> regards,
>
> bernd hilmar
>



This archive was generated by hypermail 2.1.3 : Tue Oct 19 2004 - 23:37:41 EDT