Regex for spliting on all unescaped semi-colons

Sobsoft

New Member
I'm using php's preg_split to split up a string based on semi-colons, but I need it to only split on non-escaped semi-colons.\[code\]<?$str = "abc;def\\;abc;def";$arr = preg_split("/;/", $str);print_r($arr);?>\[/code\]Produces:\[code\]Array( [0] => abc [1] => def\ [2] => abc [3] => def)\[/code\]When I want it to produce:\[code\]Array( [0] => abc [1] => def\;abc [2] => def)\[/code\]I've tried \[code\]"/(^\\)?;/"\[/code\] or \[code\]"/[^\\]?;/"\[/code\] but they both produce errors. Any ideas?
 
Back
Top