I've used Regex in Mysql to a limited extent to find various string patterns in MySql records (e.g Init Cap, All Caps). I'm trying to find a more complex pattern which also includes optional strings. I know if I simply searched on all possible patterns it would work but trying to see if RegEx is more powerful than that and would help me to at least reduce the # of patterns I need to search. Essentially the pattern is Digit Word Suffix.
1) The beginning of the pattern is always a # but anywhere from 1-5 digits. I'd prefer not to have to search on [0-9], then [0-9][0-9] etc. In other words some way to search on any digit string of 1 to 9999 (without leading zeros)
2) Between the leading digit and the suffix there can be up to three words. Again I'd prefer to not have to have a pattern match with 1,2 an 3 words. Clearly if I had to do this with each version of the digits I'd already have 4*3 patterns to search which seems inefficient
3) There is an optional modifier word that can be either after the middle word or after the suffix. As per above I'd prefer that to be indicated as such so that in essence I can simply make a regex that encompasses the following logic:
[Up to 4Digits] [Optional Modifier from Known List of Modifier Words] [One to Three Unknown Words] [Suffix from Known List of Suffix Words] [Optional Modifier from Known List of Modifier Words]
Is RegEx up to this task even partially, if so any assistance in starting this would be appreciated.