Results 1 to 3 of 3
Thread: Remove part of a string
- 09-16-2011, 11:32 PM #1
Remove part of a string
For example if I have a string like:
How can I remove the first line? For example remove everything until a '\n' and then remove the '\n'.Java Code:String str = "hello 4235 blah blah\nhello2 4353242 blah blah\n"; ... etc
By the way:
The Strings always change so I can't do str.replace("hello 4235 blah blah\n", "");Last edited by PhQ; 09-16-2011 at 11:35 PM.
-
Re: Remove part of a string
You could split the String on "\\n" and then take the parts you desire, you could use subString after finding the location of the next \n with indexOf.
- 09-16-2011, 11:52 PM #3
Similar Threads
-
Split string and remove
By drogba123 in forum New To JavaReplies: 2Last Post: 03-20-2011, 10:52 AM -
copying a part of a string and moving it to the end of the string?
By sidd0123 in forum New To JavaReplies: 9Last Post: 04-23-2010, 01:52 AM -
unicode as part of string
By mac in forum New To JavaReplies: 0Last Post: 01-28-2010, 02:23 AM -
search with part of string
By virendra in forum LuceneReplies: 1Last Post: 01-21-2010, 12:56 PM -
How to get part of a String?
By eva in forum New To JavaReplies: 1Last Post: 12-23-2007, 06:58 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks