I have a string by "This is apples, it costs me &xyz and I bought them at &abc" I need to get the folowing output "This is apples, it costs me {xyz} and I bought them at {abc}" Basically I need to replace &word with {word} Thanks Sri
Dear friend, You can use the following way also. Code: $var="This is apples, it costs me &xyz and I bought them at &abc"; $var=~s!&([a-z]{3})!{$1}!g; print "$var\n";
See the following code. It will match & followed by n number of numbers/characters. Code: [COLOR=Blue]$val =~ s/&(.*) /{$1}/g; print $val;[/COLOR]
In above code(previous post) space will not come, now I correct it. Code: [COLOR=Blue]$val =~ s/&(.*)/{$1}/g; print $val;[/COLOR] sorry, I think while copy and pasting time the space is added.