【发布时间】:2011-03-16 17:14:02
【问题描述】:
好的,所以我一直在寻找关于我的问题的几个小时,但似乎没有出现任何问题。 所以这是我的代码 sn-p 后跟问题:
Pattern forKeys = Pattern.compile("^<feature>\\s*<name>Deviation</name>.*?</feature>", Pattern.DOTALL|Pattern.MULTILINE);
Matcher n = forKeys.matcher("");
String aLine = null;
while((aLine = in.readLine()) != null) {
n.reset(aLine);
String result = n.replaceAll("");
out.write(result);
out.newLine();
}
让我们假设未声明的变量已经声明..
我的意思是,我的 RegEx(也许还有匹配器)无法正常工作。
我想擦除 ff 行中包含“<feature><name>Deviation</name>*any character/s here*</feature>”的部分:
<feature>
<name>Deviation</name>
<more words here>
</feature>
<feature>
<name>Average</name>
</feature>
<feature>
<name>Deviation</name>
sample words
</feature>
我认为我的问题是重复运算符的使用(如何遍历换行符、制表符等),但我似乎找不到正确的表达式。
有什么想法吗?提前致谢。
【问题讨论】: