regex match if or not exist part of name
Posted: 19 Mar 2017 06:55
Hi, I am regex dumb for now...
Slowly learning and have looked some examples here and on regexlib.com
But it has been few days on off when I have time but I decided to ask for some help as I believe it is quite easy (when you know it)
I have combination of these filenames
A_by_B
A_by_B-C
A_by_B-C [D]
C and [D] may or may not be in every filename
I need:
A
B
[D]- with brackets if present
So far I got this but fails if C or D is not present. (edit)
Thanks a lot.
Cheers
Slowly learning and have looked some examples here and on regexlib.com
But it has been few days on off when I have time but I decided to ask for some help as I believe it is quite easy (when you know it)
I have combination of these filenames
A_by_B
A_by_B-C
A_by_B-C [D]
C and [D] may or may not be in every filename
I need:
A
B
[D]- with brackets if present
So far I got this but fails if C or D is not present. (edit)
Code: Select all
(.+)(?:_by_)(.*)?-(.*)?(\[.*\])Cheers