my logic was to just put the space character in place of comma and keep rest as 
it is 

but unfortunately that does not work 

thanks john for your trick 


it is working now


________________________________
From: John W. Krahn <jwkr...@shaw.ca>
To: Perl Beginners <beginners@perl.org>
Sent: Thursday, April 28, 2011 7:47 PM
Subject: Re: regular expression

Irfan Sayed wrote:
> hi,

Hello,


> i have following code.
>
>
> $target = "abc,xyz";
> print "$target\n";
> $target =~ s/,/\s/g;
> print "$target\n";
>
> i need to replace "comma" with whitespace for string "abc,xyz"

"Whitespace" is something that applies only to regular expressions but 
the second part of the substitution operator is just a string, not a 
regular expression.  And which of the five whitespace characters should 
this string interpolate "\s" as: " ", "\r", "n", "t" or "\f"?


> the output shud be "abc xyz"
>
>
> the above regular expression does not do that . please suggest

$target =~ tr/,/ /;



John
-- 
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/

Reply via email to