On Nov 28, Ahmed Moustafa Ibrahim Ahmed said:

>You don't you need the line beginning and line termination in
>s/(^|[^ ]) ([^ ]|$)/$1$2/g;
>
>Would
>s/([^ ]) ([^ ])/$1$2/g
>be simpler?

But it doesn't work in all cases:

  $_ = "a ";
  s/([^ ]) ([^ ])/$1$2/g;
  print;  # "a "

But the (^|[^x]) approach can be replaced by (?<!x), and ([^x]|$) can be
replaced by (?!x).  See my other response.  This technique is NOT
optimized, so it's not very fast, so you should use the s///eg solution I
have provided.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to