I have a line like the following
DAS-1111[DR-Helpfull-R]-RUN--[121668688374]-N-[+helpfull_+string]
The above line is a formatted view in groups that looks like this:
AB[C]-DE-[F]-G-[H]
I think I like to handle some of these groups, and I like to do something like an explosion.
I say because I tried this code:
$string = 'DAS-1111[DR-Helpfull-R]-RUN--[121668688374]-N-[+helpfull_+string]'; $parts = explode( '-', $string ); print_r( $parts );
and I get the following result:
Array ( [0] => DAS [1] => 1111[DR [2] => Helpfull [3] => R] [4] => RUN [5] => [6] => [121668688374] [7] => N [8] => [+helpfull_+string] )
that this is not what i need.
I need the following output:
Array ( [0] => DAS [1] => 1111[DR-Helpfull-R] [2] => RUN [3] => [4] => [121668688374] [5] => N [6] => [+helpfull_+string] )
Can someone suggest a nice and elegant way to blow this line the way I need it?
I forgot to mention that a string can have more or less groups. Examples:
DAS-1111[DR-Helpfull-R]-RUN--[121668688374]-N-[+helpfull_+string] DAS-1111[DR-Helpfull-R]-RUN--[121668688374] DAS-1111[DR-Helpfull-R]-RUN--[121668688374]-N-[+helpfull_+string]-anotherPart
Update 1
As @axiac mentioned, preg_split can do the job. But can you please help with regex?
I tried this, but it seems that this is not true:
(?!\]\-)\-