As you asking for a generic solution? There isn't one. For example, you specified that "V2" is not a version when others (example) would consider it a version.
Worry more about the working aspect (at which you succeed) rather than the elegance aspect (which isn't really attainable here).
In reply to Re: Using a regex to extract a version from a Un*x path
by ikegami
in thread Using a regex to extract a version from a Un*x path
by gcmandrake
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |