[英]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 我已经使用stanford nlp解析了一些文本文件,我需要提取符合下面模式的文本
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", "")
Try "\\\\(NP|\\\\(JJ|\\\\(NNS|\\\\(NNP|\\\\(NN|\\\\(DT|\\\\(CD|\\\\(FW|\\\\(WHNP|\\\\(WDT|\\\\(VBN|\\\\(PRP"
试试
"\\\\(NP|\\\\(JJ|\\\\(NNS|\\\\(NNP|\\\\(NN|\\\\(DT|\\\\(CD|\\\\(FW|\\\\(WHNP|\\\\(WDT|\\\\(VBN|\\\\(PRP"
Slashes are wrong. 斜线是错误的。 Use
\\\\
instead of /
使用
\\\\
而不是/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.