Extracting number from string using regular expressions
3 answers
Personally, I would use this regex:
^.*\(\d+\)(?:\.[^().]+)?$
That being said, I can select the last number in the parentheses just before the expansion (if any). It will neither match nor accept an arbitrary number in parentheses if there are any characters in the middle of the filename. For example, he must choose the right one 2
from SomeFilmTitle.(2012).RippedByGroup (2).avi
. The only drawback is that he will not be able to distinguish when the number just before the extension: SomeFilmTitle (2012).avi
.
My guess is that the file extension, if any, shouldn't contain ()
.
0
source to share