How to make a c# regex match only the *last* occurrence of a pattern?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

I've been searching as best I can for this - coming up with little.

I have a file that is full of lines fitting this pattern:

(?<year>\d{4}),(?<amount>\d{6,7})

I'm likely to get a bunch of hits with this - I'm only interested in
the *last* one. Is there a way to build the concept "last" into the
regex itself? Or is taking the last element of the match array the only
thing to do?

I would just prefer to avoid have a potentially long array being sent
around...

Thanks,

cdj

.