I have a string that follows these rules:
- Add a capital letter, unique to the entire string.
- Then add one or more groups of the pattern \d+z where \d is a digit i.e. a digit one or more times followed by a 'z'.
- Repeat 1 and 2 above, zero or more times.
An example string that follows the above rules is:
"A42z19z037z21z" +
"B942z21z4842z" +
"C33z449z3884z68z20z"
(This is one string broken down for appearance.)
I need a regex that effectively does the following:
- Go to a specified capital letter e.g. 'B'.
- Match each group of \d+z (see rule 2 above) between this capital letter and the next capital letter.
This seems to need two separate regexes, one to find the location of 'B', then one to match groups until the next capital letter. Can this be done in one regex?
EDIT:
So, using the above example, the matches would be "942z", "21z", and "4842z".