• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt with replace all

 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • 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
  • 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: 21003
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic