PHP regex groups captures

后端 未结 4 2057
南旧
南旧 2020-12-06 16:34

I have the following regex:

\\[([^ -\\]]+)( - ([^ -\\]]+))+\\]

This match the following successfully:

[abc - def - ghi - jk         


        
4条回答
  •  温柔的废话
    2020-12-06 17:03

    This is not the job for the regexp. Match against \[([^\]]*)\], then split the first capture by the " - ".

    
    

提交回复
热议问题