Reg: replaceAll new question

N

NickName

Hi all,

I'm a newbie to the java world. Here I have a task to replace all the
occurrences of something like
"http://11.22.33.44/topLevel/secondLevel/" to something like "myServer"
against a non-relational database, namely, a database created by
Borland's CaliberRM (Requirement Management Tool).

Using a binary search tool indicates that there are over 1000
occurrences of this string, however, "binary search and replace of the
string" did not work with CaliberRM, Borland said this approach is not
supported.

Previous developer left us with a java utility program, lookinig at the
code, it indicates that it uses replaceFirst instead of replaceAll and
he uses java.util.Enumeration class, he also use "treeNodes", so,
probably that's what the Enumeration utility is about, and search and
replace is recursive, and yet, he mentioned that we may need to run the
utility multiple times for many occurrences, conflicting stuff.

The box has java jdk 1.5.0x and jre 1.5.0x installed.

Would I be better off using replaceAll method instead of replaceFirst
method?
Should I add "import java.lang.String" class?
Then in the code, would something like
/* define an object obj, OMITTED HERE
string to be replaced = http://11.22.33.44/topLevel/secondLevel/
new string = myServer
assumptions:
all of the following four characters are considered as special
characters in reg (regular express):
:
//
..
/

*/
obj.replaceAll("http\\:\\//11\\.22\\.33\\.44\\/topLevel\\/secondLevel\\/",
"myServer/")

Your critique or suggestion would be most appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top