There is a String class and some methods are associated with it. Read this class and their methods , your problem will be solved
The String class should solve the problem, providing you don't need anything exotic (like "delete all words that start with an 'h'"). But even then, you'll be able to use the given methods to solve the problem, it will be a bit more work though.
The String class should solve the problem, providing you don't need anything exotic (like "delete all words that start with an 'h'"). But even then, you'll be able to use the given methods to solve the problem, it will be a bit more work though.
Arg, didn't think of that. But at least I wasn't totally mistaken:
The package java.util.regex is only provided from java 1.4, some of it even from java 1.5 onwards, so for backwards compatibility... ^^ OK, hardly anyone uses something older than 1.5 these days, but you never know! :-D
Does anyone have suggestion what can I do to remove some string from a string?
Like this :
Original : I have a cat.
Remove : have
Result : I a cat.
Thanks in advance.
Hi,
following code will help u..
class Stringremoval
{
public static void main(String args[])
{
String sample="i have book";
StringBuffer s = new StringBuffer(sample);
StringBuffer AfterRemoval=s.delete(2,6);
System.out.println("removed part:"+removedpart);
}
}
class Stringremoval
{
public static void main(String args[])
{
String sample="i have book";
StringBuffer s = new StringBuffer(sample);
StringBuffer AfterRemoval=s.delete(2,6);
System.out.println("removed part:"+removedpart);
}
}
-Thanks & Regards
Hamsa
Spoiler: removing part of a String is identical to replacing that part of the String
by nothing, i.e. the empty String "". There's no need for all those statements
(what is "removedpart"?)
Spoiler: removing part of a String is identical to replacing that part of the String
by nothing, i.e. the empty String "". There's no need for all those statements
(what is "removedpart"?)
kind regards,
Jos
hi,
sry its not "removedpart" in tat pgm... its "Afterremoval" which is string...
wat u said also rite..(removing --replacing the string with"")