For example, return the part of the string that is after the last x in axxxghdfx445 (should return 445).
x
axxxghdfx445
445
the simplest way is not regular expression, but a simple split() and getting the last element.
$string="axxxghdfx445"; @s = split /x/ , $string; print $s[-1];