Search code examples
phppreg-split

preg_split after a word and a colon


I try to preg_split after a word and a colon.

That works for me if I split after a word:

$split = preg_split('/\b(\w*WORD\w*)\b/', $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

Now I'm looking for something to split afer my word+colon. Like Car:


Solution

  • Do you mean like this?
    (\w*:)

    http://www.phpliveregex.com/p/fxD