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.

1 Answer 1

2

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

  • /XYZ|ABC/ matches XYZ or ABC.

See Alternation from PHP PCRE regex syntax.

Sign up to request clarification or add additional context in comments.

1 Comment

Doh! guess 20 hours of beeing awake took it's toll, stupid I didn't came up with this. Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.