Results 1 to 4 of 4
Thread: replaceAll Problem
- 12-21-2010, 11:42 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
replaceAll Problem
Hi,
I'm trying to replace placeholders in a String (read in from a text file) with actual values.
The placeholders are in the format of ??name??.
What I've tried is:
sk.replaceAll("//?//?title//?//?",it.getItemName());
where sk is the String I'm replacing in.
I also tried without any /s and with a single one before each ?. However, none of them seem to make any change to sk (which has many placeholders in that format).
Could someone show me what I'm doing wrong?
Thanks,
Steve
- 12-21-2010, 11:50 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Escape with the backslash character ('\') !!
--> "\\?\\?title\\?\\?"
Strings are immutable so you(and the methods :D ) cant change the String sk. The method returns a new String, so you have to writeHowever, none of them seem to make any change to sk (which has many placeholders in that format).
sk = sk.replaceAll....
- 12-22-2010, 07:33 AM #3
if you are familiar in reg expression, you better use that in replaceAll() method..
Mak
(Living @ Virtual World)
- 12-22-2010, 01:09 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Regular Expressions and String.replaceAll()
By meta1203 in forum New To JavaReplies: 1Last Post: 11-24-2010, 11:41 PM -
replaceALL(char oldChar, char newChar) method
By arson09 in forum New To JavaReplies: 0Last Post: 04-28-2010, 05:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks