in reply to Replace a word in a line except for the last char of the word?

Hi try this,

$line = '<br> 2<br> 3<br> 4'; $line =~ s#(?= )#&nbsp#gsi; while ($line =~ s#(&nbsp) (&nbsp)#$1$2#gsi) { } print $line; o/p: <br>&nbsp&nbsp 2<br>&nbsp&nbsp&nbsp 3<br>&nbsp&nbsp&nbsp 4

gube
  • Comment on Re: Replace a word in a line except for the last char of the word?
  • Download Code