Dear Monks,
perl -e ' $string="X*X*X*X"; \ $NEW=20; \ $string =~ s/(^|[\*])X([\*]|$)/${1}${NEW}${2}/g; \ print "$string\n";'
will gives :
20*X*20*XIt seems that after first match, the first '*' which was used by 1st match, doesn't count for the 2nd match ..
Is there any modifier or another way to replace all the 'X' at once ? any trick without executing this line twice ?
Thank you very much !
edit: Thank you all for your answers, the ?= works beautiful.. very useful! :DIn reply to global string replace by zX4hzjFWWT
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |