php - using regex to separate string in groups -


i want parse string this:

[np amanda brumfield],[np estranged daughter][pp of][np actor billy bob thornton],[vp found][adjp guilty][pp of][vp aggravated][np manslaughter][pp of][np child] 

and in case recognise these groups:

[np amanda brumfield][np estranged daughter][pp of][np actor billy bob thornton] , [adjp guilty][pp of] , [np manslaughter][pp of][np child] 

in other words, should use string [vp \w+] split string.

how write regex that?

@casimir et hippolyte mentions using preg_split(), correct. following split given input way requesting:

$parts = preg_split('/\[vp\s+(?:[^\]])+\]/', $input); 

that pattern should allow pretty after initial vp , 1 or more spaces prior closing ]. php should fine non-capturing parens well.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -