Results 1 to 2 of 2
Thread: String.replace function
- 09-19-2011, 05:03 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
String.replace function
Hello
I want to replace two SubString inside a String.
I tried the code below but it did not work
If I changed to this, it will work but I believe this is not good way as I have to create 3 StringsJava Code:public String getFormattedString (String var1, String var2) { String rawText = "Name [name] and price [price]"; rawText.replace("[name]", var1); rawText.replace ("[price]", var2); return rawText; }
Can you please helpJava Code:public String getFormattedString (String var1, String var2) { String rawText = "Name [name] and price [price]"; String temp = rawText.replace("[name]", var1); String formattedText = temp.replace ("[price]", var2); return formattedText; }
Many thanks
john
- 09-19-2011, 05:07 AM #2
Similar Threads
-
String.replace ?!
By HearT.Hunt3r in forum New To JavaReplies: 4Last Post: 08-22-2011, 03:04 AM -
Getting an IllegalArgumentException when using the replace() function
By Gorgro in forum AWT / SwingReplies: 1Last Post: 11-20-2010, 11:28 PM -
Replace String
By Raeghin in forum New To JavaReplies: 1Last Post: 07-28-2009, 03:58 PM -
string replace problem
By soni in forum Advanced JavaReplies: 8Last Post: 07-06-2008, 01:21 AM -
Find and replace ( in a String
By hamish10101 in forum New To JavaReplies: 6Last Post: 01-17-2008, 05:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks