Hey Guys,
I'm having problems creating a regular expression which will fix a valid string.
The string will be in the format: any alpha-numerical character 3 to 5 times, followed by a comma if there are more characters after else its the end of the string
Example Strings: A401,CR56,4U9Y,MO16,ECZGB,A7DC,9LN5,D52PU,UT95,YBPB0,2JWA,AAMW,KVG,6V8W,FWE
TRIR,J107,Q9X,FMFZ,VDAS,557,X7A,DRPB,S97O,8U62B,IN3I,H8MC,WS4C,U04KQ,X05O.
I have tried a few various expressions, but none which seem to match if I have an invalid entry. I know I could explode the string, and loop through the array, but trying to do this in just the one expression as it seems a pretty easy one, but can't quite figure it out.
Exmaple patterns:
echo preg_match("/^([A-Z0-9]{3,5})[,|$]{1,}/",$str);
echo preg_match("/((?<=[^|,])([A-Z0-9]{3,5}){1}(?=[,|$])){1,}/",$str);
and various variations on them, but I can't quite find the winning pattern, all help appreciated.
Cheers, Psy