OK, so I'm searching for hours about my problem but nothing seems to happen. So here is my code snippet, after which there is a problem:
for the pattern KEY = Pattern.compile ("^ gtc: \\ s * & lt; name & gt; ; Deviation & lt; / name & gt; *? & Lt; / feature & gt; "pattern .dotall; pattern multitine); Matcher n = forKeys.matcher (""); String align = empty; While ((aLine = in.readline ()) = null) {n.reset (Aline); String result = n.replaceAll (""); Out.write (results); Out.newLine (); } Assume that the undeclared variables are already declared.
I have to say that my Reggae (and maybe even Mitcher) is not working properly.
I get " gt; & lt; name & gt; deviation & lt; / name & gt; * any character / s here * & lt; / feature & gt; ; I want to erase parts with FF line: gt; & lt; name & gt; deviation & lt; / name & gt; & lt; Lt; here more words & gt; & lt; / feature & gt; & lt; feature & gt; & lt; name & gt; avg & lt; / name & gt; & lt; / feature & gt; & lt; Feature & gt; & lt; name & gt; deviation & lt; / name & gt; sample word & lt; / feature & gt; I think my problem is again Uses (line breaks, tabs, etc.) How to overcome it? But I can not find the correct expression.
Any thoughts? Thanks in advance.
.
Use an XML parser and things will work better.
There is a solution to use your problem here:
// parse XML source document document = DocumentHelper.parseText (yourXmlText); Iterator & lt; element & gt; FeatureIterator = // Get an iterator for all & lt; Feature & gt; Element document. Gatereit element (). ElementIterator ("feature"); While (featureIatorator.hasNext ()) {Element FeatureElement = FeatureTitre.Next ()); // if & lt; Feature & gt; A child is & lt; Name & gt; If the content ("deviation") is equal with the "deviation" (convenience element.LimitTextTrem ("name")) {// it & lt; Feature & gt; Element utility .remove (); }} // Write the modified XML back to the new XMLWriter file (new FileOutputStream (yourXmlFile), OutputFormat.createPrettyPrint ()) .write (document); In addition, you are making a mistake (see my comments): // Only one row while ((ALine = In.readLine ()) = null) {n.reset (alien); // So far you want to replace a multi-line pattern string result = n.replaceAll (""); Out.write (results); Out.newLine (); } If you read the whole file in a string, your regex may or may not work, but it can not work if applicable to individual lines.
Comments
Post a Comment