My methods parse strings and do stuff with the information contained in the string. a simple example would be
$string=
"
user:name,password={$_POST['name']}, {$_POST['password']}(md5);
names:name=name;
";
$class->$method($string);
The above would do two insert statements. The first will insert in a table named user the users name and the password encypted in md5.
the second would insert a name in the names table. I'm having setting it up so that characters can be escaped. ie if the users name was p;ez. The string would have p\;ez.
My current method is as follows
#get position of ;
$offsetSemi=stripos($s, ";");
#check if its escaped
if ($s[$offsetSemi-1]!='\\')
{
//not escaped
}
the problem with the above method is that it will only check the first instance of ;. the other solution i tried was exploding the string on ;. however this would not work because it exploded on all instances including ones that were escaped. the other thing i tried was an explode with the regular expression below
/[^\\\];/
the prolem with this is that it exploded on the charecter before ; on all the instances that were not escaped. is there a way i can explode a string on all instances of ; that are not preceded by a backslash?