For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2005 > Re: regex remove of strings etc









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: regex remove of strings etc
Muthukumar

2005-08-23, 7:55 am

> I need to remove the string "room" (notice the check for a space too) and=
also to check for spaces in the beginnig and then maybe at the end
> of the total string.
>=20
> $p110rm01 =3D~ s/(\sroom|^\s*|\s*$)//igo;
>=20


It is correct. You can try as,

# echo " hi this is a room ok" | perl -ne 'if ( /\s*.*\sroom.*\s*/ ) {
s/ room//;}print;'
# hi this is a ok

hth.
Brent Clark

2005-08-23, 7:55 am

Muthukumar wrote:

> It is correct. You can try as,
>
> # echo " hi this is a room ok" | perl -ne 'if ( /\s*.*\sroom.*\s*/ ) {
> s/ room//;}print;'
> # hi this is a ok


Hi
you the man
I cant believe I was sooo stupid in not thinking of your solution.

thanks again

Brent Clark
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com