On 11-04-28 10:05 AM, Irfan Sayed wrote:
hi,

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"

the output shud be "abc xyz"


the above regular expression does not do that . please suggest


--irfan

The white space meta-character does not work on the replace side of a substitution. Use a space character:

$target =~ s/\,/ /g;

Some people prefer to use the hexadecimal format because in some fonts, it's hard to distinguish between // and / /. Having something visible makes the meaning clear.

Like this:

$target =~ s/\,/\x20/g;


--
Just my 0.00000002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

--
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