Results 1 to 7 of 7
Thread: String replacement...
- 05-17-2010, 07:55 AM #1
Member
- Join Date
- May 2010
- Posts
- 25
- Rep Power
- 0
- 05-17-2010, 12:33 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Many ways to do it. In String class you can find a method replace() for string replacing. Read the API for find the argument list.
- 05-17-2010, 12:34 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Java Code:String str="abc %d %s %t %h %o"; System.out.println(str.replace( "%d","Apple" ));
- 05-17-2010, 03:50 PM #4
Member
- Join Date
- May 2010
- Posts
- 25
- Rep Power
- 0
Hi,
was told that there's formatter class that i can use in Java.
but formatter class only does the standard, %f, %s, %d....
Can i add customer format to the formatter like %o, %i....
- 05-19-2010, 03:46 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Then you've to think about the way of replacing stuff. You may keep things in a map and use, if you can. Sine I don't know the exact thing I cannot say exactly which way to go.
Looking at your last post, I feel that you want to format a string, not replace, even both are quite similar.
- 05-19-2010, 04:06 AM #6
Member
- Join Date
- May 2010
- Posts
- 25
- Rep Power
- 0
- 05-19-2010, 04:20 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Actually for replace you can find more ways, such as replaceall() and stuff. Refer the API you can find more information.
Similar Threads
-
The constructor Person(String, String, Date) is undefined
By fh84 in forum New To JavaReplies: 7Last Post: 11-03-2009, 02:18 AM -
combine string[] into string like perl's join function
By tekberg in forum Advanced JavaReplies: 9Last Post: 02-23-2009, 01:05 PM -
Let eclipse warn about a semicolon after an if statement and string == string?
By foobar.fighter in forum EclipseReplies: 5Last Post: 01-11-2009, 10:12 AM -
Looking for JGroups replacement
By asynchrony in forum NetworkingReplies: 4Last Post: 10-17-2008, 10:54 PM -
Using java.util.Scanner to search for a String in a String
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 04:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks