I want to split using multiple delimiters including -:|/
. Here is my current code:
preg_split( "/ [-:|] /", $body);
Now I have problem with /
. Any ideas?
I want to split using multiple delimiters including -:|/
. Here is my current code:
preg_split( "/ [-:|] /", $body);
Now I have problem with /
. Any ideas?
preg_split( '~[-:|/]~', $body);
ps: and, I suppose, there should be no spaces around [ ], but it depends on your situation.
To use the delimiting character inside a regular expression, escape it using a \
.
preg_split("/ [-:|\\/] /", $body);
Better, you can use other any other delimiter. Various characters will work:
preg_split("@ [-:|/] @", $body);
preg_split("# [-:|/] #", $body);