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

s/ (?= )/ /g;

Caution: Contents may have been coded under pressure.
  • Comment on Re: Replace a word in a line except for the last char of the word?
  • Download Code

Replies are listed 'Best First'.
Re^2: Replace a word in a line except for the last char of the word?
by cog (Parson) on Mar 11, 2005 at 12:20 UTC
    Allow me to explain :-)

    (?=) matches only if what's between the "=" and the ")" is found to the right of the expression. This means the expression matches a space *only* if it is followed by another space.