xorinzor
xorinzor

Reputation: 6467

Split string by multiple (more specific) delimiters in PHP

I know this question has been asked a million times, though I can't really find the answer for my question.

I read the answer from this question How to split a string by multiple delimiters in PHP?

Which looks fine, however I'm not sure about what pattern I should use when I want to use delimiters like:

it's important for the spaces to be included.

Upvotes: 1

Views: 102

Answers (1)

falsetru
falsetru

Reputation: 368944

Use /\s*(&|feat|vs\.)\s*/ as pattern.

  • /XYZ|ABC/ matches XYZ or ABC.

See Alternation from PHP PCRE regex syntax.

Upvotes: 2

Related Questions