mengwong (mengwong) wrote,
mengwong
mengwong

Negative lookbehind regular expression match

In the following negative lookbehind regexp,

  20120716-01:01:55 mengwong@cny2:~% perl -ple 's/(?<!a)b/a/g'

abb correctly becomes aba

  abb
  aba

But bbb wrongly becomes aaa.

  bbb
  aaa

Discuss.

20120716-01:02:17 mengwong@cny2:~% perl -v                  
This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
Tags: perl, regexp
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 5 comments