Starting a new question as my other question solved a different issue with the regex.
Here's my regex:
(?i)\\d{1,4}(?<!v(?:ol)?\\.?\\s?)(?![^\\(]*\\))
Regex split up for clarity:
(?i)
- case insensitive
\\d{1,4}
- a number with 1-4 digits
(?<!v(?:ol)?\\.?\\s?)
the number cannot be preceded by 'v', 'v.', 'vol', 'vol.', with or without a space on the end.
(?![^\\(]*\\))
- Number cannot be inside parentheses.
It all works except for the 'vol.' bit.:
@"Words words 342 words (2342) (words 2 words) (words).ext"
result 342 - correct.
@"Words - words words (2010) (words 2 words) (words).ext"
result nil - correct.
@"words words v34 35.ext"
result 34 - incorrect.
@"Words vol.342 343 (1234) (3 words) (desc).ext"
result 342 - incorrect.
What am I doing wrong with my 'vol.' section?