in reply to Re^2: Work-around for variable length look-behind?
in thread Work-around for variable length look-behind?

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.
RIP an inspiration; A true Folk's Guy