1

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:

  • " & "
  • " feat "
  • " vs. "

it's important for the spaces to be included.

Community
  • 1
  • 1
xorinzor
  • 6,140
  • 10
  • 40
  • 70

1 Answers1

2

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

  • /XYZ|ABC/ matches XYZ or ABC.

See Alternation from PHP PCRE regex syntax.

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • 1
    Doh! guess 20 hours of beeing awake took it's toll, stupid I didn't came up with this. Thank you so much! – xorinzor Nov 17 '13 at 07:03