My problem is I'm trying to validate input submitted on a form as semi-colon delimited coordinates. I only want to accept data that holds the following pattern:
1,2
1,2;3,4
1,2;3,4;5,6
etc.. up to any length of coordinates.
It should fail where the semi-colon or comma is in the wrong place...
e.g. 1;2;3,4
I'm pretty new to both regex and PHP. I used regex101.com to come up with something what I have been trying is:
if (!preg_match('/(\d+,\d+;)*\d+,\d+/', $coordinateData)) {
return;
}
This matches my pattern but it also matches when the semicolon is in the wrong place.
I would really appreciate help.