in reply to Regex to extract digits

"I want to extract the two right most digits after the minus sign."

There are different ways to understand what you said, and the example you given might just be one of the pattern you have.

For example, I could say this meets your requirement:

use strict; use warnings; my $str = "25364-564756ABCD"; $str =~ /-\d*?(\d{2}).*$/; print $1;

It would be a good idea to give more examples to cover more of your patterns, if you actuall have.

Replies are listed 'Best First'.
Re^2: Regex to extract digits
by Skeeve (Parson) on Oct 09, 2004 at 10:09 UTC
    This would meet too: /-.*(\d\d)/

    It will match the leftmost - and then greedy match anything up to the last to digits. Surely those two will be the "righ most digits after the minus".

    $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print