If I have strings such as these:
1. AB-123
2. AB 123
3. AB-123-1
4. AB 123-1
5. AB XYZ-1
I need a regular expression that determine if the end contains /\-\d+$/ and only #3, #4, and #5 to qualify.
The problem I'm running into is that the above regex matches for #1, #3, #4, and #5 since they all have hyphens.
If there's a nice regex that can be used to solve this, that would be great. Otherwise, I'm open to javascript, such as using the split function. I've been trying that unsuccessfully, too.
var splitter = str.split(/\-\d+$/)
I just don't have a good way to tell if the string qualifies with /\-\d+$/ when there are possible hyphen instances earlier in the string.
Our community of experts have been thoroughly vetted for their expertise and industry experience.