[英]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? 我读过这个问题的答案, 如何在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. 对于包含空间很重要。
Use /\\s*(&|feat|vs\\.)\\s*/
as pattern. 使用
/\\s*(&|feat|vs\\.)\\s*/
作为模式。
/XYZ|ABC/
matches XYZ
or ABC
. /XYZ|ABC/
匹配XYZ
或ABC
。 See Alternation from PHP PCRE regex syntax. 请参阅从PHP PCRE regex语法替代 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.