I am trying to validate a complex regex, but I'm not too sure how to begin with my approach. I am changing different things using a regex tester, but it's a bit complicated. I am using Angular's Validator.pattern to verify this text input.
The string I am testing validation on is:
1;D;00:00|04:59|5%;05:00|8:59|35%;09:00|14:59|35%;15:00|23:59|25%,2;D;00:00|04:59|5%;05:00|14:59|30%;15:00|23:59|65%
The way it is broken down is it is comma delimited between objects and each object has different parts that are delimited by semicolons
First part: 1, this can be any positive integer, my best guess would be something like ^\d+$?
Second Part: D, this can be either A or D, something like this: [AD]?
Third Part: 00:00|04:59|5%;05:00|8:59|35%;09:00|14:59|35%;15:00|23:59|25%, this part would be the most complicated. It would take in 2 time ranges and then a percent between 0-100%, each part separated by a | delimiter. The ranges should ideally add up to 100% and the time ranges to not overlap, but that validation can be done in a separate service, I just want the format correct as of right now. So as long as the input would be 2 time ranges and a percentage, it would be accepted.
https://regex101.com/r/hPXPE8/1
I created a regex tester to test things out if that makes it easier.
(?:[;,]|$)