Forums Register Login

How to wipe off the whitespace in the String

+Pie Number of slices to send: Send
Hello Everybody!
if there is one function that can wipe off white space in the jdk.if not,can anyone give me some advice?Thanks a lot
+Pie Number of slices to send: Send
Just call the trim() method.
For Example:
String str = "Hello World    ";
str = str.trim() // would give "Hello World"
if you want to remove whitespaces within a string, one way of doing it is:

Wendal
[ June 24, 2003: Message edited by: Wendal Park ]
+Pie Number of slices to send: Send
Hello
if you want to replace all there is also a function in 1.4....
replaceAll(String regex, String replacement)
Replaces each substring of this string that matches the given regular expression with the given replacement.
My, my, aren't you a big fella. Here, have a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1116 times.
Similar Threads
Adding alerts to Reset button
please help me to learn unix online.
Effects of Globalization(Outsourcing)
One night @the call center
question from HFSJ
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:49:06.