I have a XML file which I parse and write the value of the node to a String. The XML tag is like,
<description>Search - Query Tab
Hide the Query Tab</description>
When I write this to a String I need to identify if there is any line feed in the given String and replace it with hard coded "\n" in it. (NOTE : Only if there is a line feed in it)
I tried to Pattern match to identify if there are any \r or \n.
descriptionBaseTerm is the <description> tag value
The if loop where I split the term using the same reg exp works fine returns the String as
"Search - Query Tab\n Hide the Query Tab". Which is the desired output.
I have done it the same way as you have quoted.
But I was wondering why Pattern Matcher didnt work.Also wanted to know if there are any other syntax to find line feed using Patterns.
Manju Krishna wrote: But I was wondering why Pattern Matcher didnt work.
But in your original post you say, it(P&M) works
Manju Krishna wrote: Also wanted to know if there are any other syntax to find line feed using Patterns.
I don't think so.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
Matcher.matches() checks whether the entire region is matched by the regexp, not whether the pattern matches anywhere in the region; Matcher.find() does that.
Ulf Dittmer wrote:Matcher.matches() checks whether the entire region is matched by the regexp, not whether the pattern matches anywhere in the region; Matcher.find() does that.