KingSmellyMcBumm
New Member
I was looking to split a string based on a regular expression but I also have interest in keeping the text we split on:\[code\]php > var_dump(preg_split("/(\^)/","category=Telecommunications & CATV^ORcategory!=ORtest^caused_byISEMPTY^EQ"), null, PREG_SPLIT_DELIM_CAPTURE);array(4) { [0]=> string(34) "category=Telecommunications & CATV" [1]=> string(18) "ORcategory!=ORtest" [2]=> string(16) "caused_byISEMPTY" [3]=> string(2) "EQ"}NULLint(2)\[/code\]What I do not understand is why am I not getting an array such as: \[code\]array(4) { [0]=> "category=Telecommunications & CATV" [1]=> "^" [2]=> "ORcategory!=ORtest" [3]=> "^" [4]=> "caused_byISEMPTY" [5]=> "^" [6]=> "EQ"}\[/code\]Additionally, how could I change my regular expression to match "^OR" and also "^". I was having trouble with a lookbehind assertion such as: \[code\]$regexp = "/(?<=\^)OR|\^/"; \[/code\]