in reply to Work-around for variable length look-behind?

Maybe?

$s = 'bbaaccbab sdcbalsbadcnw';; $s =~ s[(b)(?=[^\s]+$)][B]g;; bbaaccbab sdcBalsBadcnw

Replies are listed 'Best First'.
Re^2: Work-around for variable length look-behind?
by pat_mc (Pilgrim) on Oct 11, 2010 at 10:47 UTC
    Oh no ... how brilliant is this? You finally opened my eyes to the fact that non of the 'b's in the second word are succeeded by a whitespace anymore ... it is pretty obvious ... but I simply did not hit upon it myself.

    This solves my problem.
    Thanks again!

    Cheers -

    Pat
Re^2: Work-around for variable length look-behind?
by mjscott2702 (Pilgrim) on Oct 11, 2010 at 10:54 UTC
    Does that take care of the "in front of an 'a'" requirement? I like it, just trying to figure out what it does?
      Does that take care of the "in front of an 'a'" requirement?

      Er, no. I missed that bit of the spec, but it is easily corrected:

      $s = 'bbaaccbab sdbcbalsbadcbnw';; ## with added bs ($t = $s) =~ s[(b)(?=a[^\s]+$)][B]g; print $t;; bbaaccbab sdbcBalsBadcbnw

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.