aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt with replace all Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt with replace all" Watch "Doubt with replace all" New topic
Author

Doubt with replace all

chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

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.


Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

I got the answer. Sorry for bothering for such a simple reason.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19066
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt with replace all