in reply to REGEXP: only need last matching string
You could use a negative look behind assertion to do this:
($dum) = $str =~/(?<!abc).*abc\s(\d+)/gs;To read more about this feature, along with lots more on regex, check out perlre.
Update: Another way to do this is explained in Roy Johnson's post on look-ahead and look-behind. I knew I had seen this before, but couldn't find it when I was first answering your question.
/abc(?!.*abc)\s(\d+)/sNot sure which is easiest for you to understand, but either way I would recommend reading that post. (Thanks to prasadbabu for linking to it in a later node so I could find it again!)
|
|---|