This is not a regex question, rather an API schema question.
To support repeating patterns of various formats you can define a {repeat}...{/repeat}
schema, or a {start_repeat}...{end_repeat}
schema. Using your examples:
Client 1 API example:
https://www.client1.com/update?students=00001,00002,00003&age=18,15,17
Client 1 API schema:
https://www.client1.com/update?students={repeat}{student_id}{/repeat}&age={repeat}{age}{/repeat}
Client 2 API example:
https://www.client2.com/update?00001:18,00002:15,00003:17
Client 2 API schema:
https://www.client2.com/update?{repeat}{student_id}:{age}{/repeat}
Then, to compose the URL on your end, you globally extract {repeat}
... {/repeat}
, and for each repeat, loop through your students, resolving {student_id}
and {age}
.
This repeat schema assumes a ,
separator. If your clients have different separators, you could enhance the schema with {comma_repeat}...{/comma_repeat}
, {semicolon_repeat}...{/semicolon_repeat}
. Alternatively, keep the repeat schema as is, and introduce a {repeat_separator};{/repeat_separator}
that should preceded any {repeat}...{/repeat}
patterns.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…