File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt with replace all

 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to improve my grip over regex. So, i wrote the small code to replace a pattern. The pattern that i want to replace is:
replace: <Node> anything in between</Node> with: <Node> Hello </Node>

The following is the regex that im using: <Node>.</Node>

As per my understanding, a "."(dot) matches everything. But when i run it, it is not doing the needful.

Where am i getting wrong?

P.S: It is not an xml file. Just XML tags in a String.
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the answer. Sorry for bothering for such a simple reason.

 
Henry Wong
author
Marshal
Pie
Posts: 20835
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chander shivdasani wrote:
As per my understanding, a "."(dot) matches everything. But when i run it, it is not doing the needful.


Yes, a "." matches any character. So, if you have exactly one character, doesn't matter what character, between the node tags, it will work.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic