Within legal descriptions it is not uncommon to have compounded Section, Township, Range. A standard S-T-R is like this 18-8N-12E where the numbers can be 1 or 2 digits and the center T portion and ending R portion are followed by a single uppercase direction letter. Sometimes the legal is compounded with several beginning sections that are comma separated such as ' 5,7,8,18-8N-12E ', meaning the sections are 5,7,8,18 in the same township-range of 8N-12E. I'm trying to come up with the best way to capture this sort of string which can vary with the number of sections following this similar comma separted pattern, and must be followed with the exact S-T-R legal pattern. The goal is to capture the repeating pattern as well as the exact S-T-R legal pattern following it.
In this example:
text = ' 5,7,8,18-8N-12E '
I'm testing with the following regex
>>> re.findall('(\d{1,2}(,\d{1,2})+)+,(\d{1,2}-\d{1,2}[A-Z]{1}-\d{1,2}[A-Z]{1})', text)
[('5,7,8', ',8', '18-8N-12E')]
which works and I could parse what I'm wanting from it, but I suspect there is a better way, so what is the best approach to capturing this?
Thanks