I have several different types of string inputs. Some may have 3 alpha characters at the beginning with the rest numbers, some may have 1 alpha as the first character with the rest as numbers and some may have 2 alpha in the beginning with the rest as numbers. For example: PLA08181; M24082137 AND MX23181. I am only interested in loading a phrase based upon the first 3 being alpha OR the first alpha on a string that has one character as the index(0) and the rest numeric. Additionally, in this latter scenario I am only interested in the first alpha being “M” or “D”. I did a regexmatch for the former as [A-z]{3}[0-9]* and am successful. However, struggling with the latter scenario where I want ONLY phrases that start with a single alpha character and the rest of the string being numerical and that single alpha must be M or D. Suggestions on this latter regex?
Thanks prasath…I already have a Match with [A-z]{3}[0-9]* which handles excluding the phrases with only 2 beginning alpha characters and captures those with 3 beginning alphas. I think for the scenario where I ONLY want to capture a phrase that has one alpha character and the rest numbers AND begins with M or D I might have to do a replace statement to replace all numbers with “” and then look for the first character (0) in an if statement to see if it is M or D. I was hoping that [A-z]{1}[0-9]* would work in a Match but it does not
Thoughts?
I actually got to the same solution with a different regex but I like yours better as it is easier to understand for other developers that are not familiar. Thanks.
Here is a new variant…BRL1817LF1. I want to ignore anything that has a combination of letters and numbers at the end. For example, of the two strings BRL1817 and BRL1817LF1, I ONLY want to capture BRL1817 and ignore the other. My original [A-z]{3}[0-9]* pulls both in …thoughts on this?
Man…didn’t even think of that! Thanks so much!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.