Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to escape $ character on unix

807605Sep 28 2007 — edited Sep 28 2007
Hi:

I have to subsitute the following line in a file with a value -
${myhome.mydir}/newloc/newfile;
Now, I have the value to subsitute the above and i use the line.replaceFirst(find_string, replace_string) command to do the subsitution. In that
find_string = "\\$\\{myhome.mydir}\\/newloc\\/newfile;
replace_string=C: + directory_separator + Temp + directory_separator + File1;
The subsitution works fine on windows but chokes at the $ subsitution on LINUX. ie if i remove the $ from ${myhome.mydir}/newloc/newfile, and then redefine the find_string in my java code to be "\\{myhome.mydir}\\/newloc\\/newfile; then the subsitution happens.

But I cannot change the original line.
Please let me know what I need to change in my find_string syntax so i could run replace_first fine on both windows and *nix platforms?

Thanks a lot!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2007
Added on Sep 28 2007
22 comments
307 views