I am trying to parse a string as shown below using a .NET regular expression:
H3Y5NC8E-TGA5B6SB-2NVAQ4E0
and return the following using Split: H3Y5NC8E TGA5B6SB 2NVAQ4E0
I check each character for a specific character set (note that the letters "I", "O", "U" and "W" are missing), so using string.Split is not an option. The number of characters in each group may vary, and the number of groups may also vary. I use the following expression:
([ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8}-?){3}
This will correspond to exactly 3 groups of 8 characters. All more or less do not match. This works because it matches the input correctly. However, when I use the Split method to extract each group of characters, I just get the final group. RegexBuddy complains that I repeated the capture group and that I should place the capture group around the repeating group. However, none of my attempts to do this achieve the desired result. I tried the following expressions:
(([ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8})-?){4}
But that will not work.
Since I generate a regular expression in the code, I could just expand it by the number of groups, but I was hoping for a more elegant solution.
, . . , , , . 'I', 'O', 'U' 'W' .
, , , .