I currently have the regex:
(?:(?:CD)|(?:DISC)|(?:DISK)|(?:PART))([0-9]+)
currently this will match CD1, DISK2 etc
I need it too be able to pick up CD02 (with two digits) as well as CD2 but I only seem to be able to do one or the other, and my regex skills are pretty useless.
I’m using this code in C#
thanks for your help
Russell
Could it be that you’re looking for the entire string “CD2” or “CD02” in a capture group? As in:
You may have made a mistake by using the
?:expression because this tells the regex engine to match the group and then discard it from the capture groups. Some other expressions you might want to consider: