How can I regex match with this format?
a1=q1,a2=q2,a3=q3,a4=q4 (this is correct sample and a characters will be utf-8)
a1=q1,a2=q2,a3=q3,a4=q4, (faulty sample)
If string have last comma character, how can I exclude last comma in regex?
My sample php code is:
$pattern="/^(\p{L}\=\p{L},?)*$/u";
$string1="a1=q1,a2=q2,a3=q3,a4=q4"; //correct
$string2="a1=q1,a2=q2,a3=q3,a4=q4,"; //incorrect
if (preg_match($pattern,$string1,$m)) { echo "correct"; } else { echo "incorrect"; }
if (preg_match($pattern,$string2,$m)) { echo "correct"; } else { echo "incorrect"; }