Monday, 26 August 2013

Regex to match this pattern

Regex to match this pattern

i have parsed some text files using stanford nlp from that output i need
to extract text which matches below pattern
open bracket followed by NP or NNP or NNS etc
Input string
(NP (DT the) (NNP sample) (NN program))
result string
the ) sample ) program )
I have tried the below regex but it's not matching my required pattern
`test.replaceAll("//(//NP|//(//JJ|//(//NNS|//(//NNP|//(//NN|//(//DT|//(//CD|//(//FW|//(//WHNP|//(//WDT|//(//VBN|//(//PRP",
"")`

No comments:

Post a Comment