in reply to Re^2: matching operator question
in thread matching operator question

If you're matching a simple string (e.g. 'b'), as opposed to a general regexp pattern, then I think the rindex solution proposed by Transient and Animator is the way to go. For more complicated matches, you could use a negative look-ahead assertion to single out the last occurrence; e.g. to replace the last occurrence of the pattern /[AB]/ with X, you could use

s/[AB](?!.*[AB])/X/s
This will replace the last occurrence of A or B with X. The /s modifier is necessary in case the string contains embedded newlines.

the lowliest monk