Results 1 to 4 of 4
Thread: Removing words from a String
- 03-15-2011, 10:09 AM #1
Member
- Join Date
- Sep 2008
- Posts
- 85
- Rep Power
- 0
Removing words from a String
I have a string e.g
Can you suggest me the best way to identify all the appearance of the word Sony Ericsson from the above string and replace it with Sony~Ericsson. So that the final o/p string isJava Code:String abc = "Sony Ericsson is one of the top, global, mobile phone manufacturers. Sony Ericsson is a joint venture established on October 1, 2001"
Java Code:String output= "Sony~Ericsson is one of the top, global, mobile phone manufacturers. Sony~Ericsson is a joint venture established on October 1, 2001"
Last edited by nn12; 03-15-2011 at 10:13 AM.
- 03-15-2011, 10:18 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Have a look at the String.replaceAll( ... ) method (read the API documentation for the String class).
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-15-2011, 10:25 AM #3
Member
- Join Date
- Sep 2008
- Posts
- 85
- Rep Power
- 0
Yes Josah. I too was thinking of the same lines, but was not sure how to write an regex for the same. If anyone has prior experience with regex, can you help me out.
- 03-15-2011, 10:50 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Removing last character from a String
By newToJava3 in forum New To JavaReplies: 2Last Post: 11-28-2010, 12:43 AM -
[SOLVED] How to count the number of words in a string
By andy5605 in forum New To JavaReplies: 8Last Post: 02-04-2009, 08:55 PM -
Extracting words from a string using delimiters
By toad in forum New To JavaReplies: 4Last Post: 07-07-2008, 01:32 PM -
program help: Extracting words from a string
By toad in forum New To JavaReplies: 1Last Post: 11-04-2007, 06:39 PM -
Analyze a string of words
By zoe in forum Advanced JavaReplies: 2Last Post: 07-26-2007, 10:01 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks