Regex Help
Posted: Thu Apr 19, 2018 12:53 pm
I'm really struggling with this. I've asked all over the internet, read every document, studied every tutorial... you get the picture!
We have filenames in the following format :
000000a-COMPANY-BRAND-SUBBRAND-Item-Additional Info-V01
I want to be able to plug into the search a term to extract a certain field.
So if the file is to be sorted by Company, regex a match for the second section of the filename. Or if I need to get the Additional Info I can just match for that.
Let me break it down a little further...
000000 ..............: Always 6x digits / Always in this position relative to the left of the string
a .......................: Always a single letter / Always follows the numbers / Will always be the 7th character
- ........................: Always in this position relative to the left of the string / Always a hyphen
COMPANY ...........: Always in this position relative to the left of the string / Always 7x letters
- ........................: Always in this position relative to the left of the string / Always a hyphen
BRAND ................: Always in this position relative to the left of the string / Always 6x letters
- ........................: Always in this position relative to the left of the string / Always a hyphen
SUBBRAND ............: May or may not exist / Could be any combination of any characters
- ........................: May or may not exist
Item ...................: May or may not exist / Could be any combination of any characters
- .......................: May or may not exist
Additional Info ........: May or may not exist / Could be any combination of any characters
-....................... : May or may not exist
V01............: Always exists / Always a capital V followed by two digits / Always in this position relative to the righthand end of the string
I have any number of failed attempts, and to be honest I don't think it would help if I posted them.
Any thoughts?
We have filenames in the following format :
000000a-COMPANY-BRAND-SUBBRAND-Item-Additional Info-V01
I want to be able to plug into the search a term to extract a certain field.
So if the file is to be sorted by Company, regex a match for the second section of the filename. Or if I need to get the Additional Info I can just match for that.
Let me break it down a little further...
000000 ..............: Always 6x digits / Always in this position relative to the left of the string
a .......................: Always a single letter / Always follows the numbers / Will always be the 7th character
- ........................: Always in this position relative to the left of the string / Always a hyphen
COMPANY ...........: Always in this position relative to the left of the string / Always 7x letters
- ........................: Always in this position relative to the left of the string / Always a hyphen
BRAND ................: Always in this position relative to the left of the string / Always 6x letters
- ........................: Always in this position relative to the left of the string / Always a hyphen
SUBBRAND ............: May or may not exist / Could be any combination of any characters
- ........................: May or may not exist
Item ...................: May or may not exist / Could be any combination of any characters
- .......................: May or may not exist
Additional Info ........: May or may not exist / Could be any combination of any characters
-....................... : May or may not exist
V01............: Always exists / Always a capital V followed by two digits / Always in this position relative to the righthand end of the string
I have any number of failed attempts, and to be honest I don't think it would help if I posted them.
Any thoughts?