Q:

Regex construction assistance

I've become stuck constructing a regex, and was wondering if you guys could help me out.
Here's the full string:
/20271/Avtal%202013/Sammanst%c3%a4lld_produktlista_2013_v121220_l%c3%a5st_web.xls

I want to extract 2013_v121220 but the matching must follow a couple of rules:

Total length of version string must at least be 4 characters
It must allow for version strings that do not contain either "v" or "_", i.e. 2013121220 or 2013_121220
The version string must be the last occurrence before the end of the string (i.e. do not match /20271/ in this case).

I've tried with (\d+[_v]*\d+).*?_web(\.xlsx?)$ but I have no idea how to implement the length check here, i.e. (\d+[_v]*\d+) has to be at least 4 characters, {4,}, this to not match the 5 in _l%c3%a5st_web.xls.

I've come up with this regex: (\d[\d_v]{2,}\d).*?_web(\.xlsx?)$ but it only matches the first occurence, I need the last one, closest to the end. I've tried prefixing .+ to the regex but it fails regardless.

A:

I managed to solve this myself. Thanks for your efforts though, I really appreciated your 
help.
This regex matches exactly according to my rules:
(\d[\d_v]{2,}\d)(?!.*\d[\d_v]{2,}\d).*?_web(\.xlsx?)$

