I\'m struggling with using regex to capture some optional text - it\'s in the middle of some filenames, but not all. The big problem appears to be that my optional group is not
Try putting the .*?(foo) parts in parentheses like (.*?(foo)) so that the ? operator will take the .*? parts into consideration.
.*?(foo)
(.*?(foo))
?
.*?
Corrected syntax (.*?).\(?(\d{4})(.*?(color))?.*?(shape)(.*?(color))?(.*?(version))?.* (example)
(.*?).\(?(\d{4})(.*?(color))?.*?(shape)(.*?(color))?(.*?(version))?.*