tags:

views:

65

answers:

2

I now split the sting op , only like this:

$a_string = preg_split('/[,]/', $sting);

I also want to split the sting on " and " but i can't find the right regex.

A: 
preg_split('/(?:,| and )/', $sting);
Martijn Laarman
+2  A: 

You can also just do:

$arr = preg_split('/,| and /', $str);

as | (alteration) has a very low precedence and binds last.

codaddict
true, I am a sucker for (?:) grouping though reads better and less error prone :)
Martijn Laarman
@Martijin: Agree :)
codaddict