You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by rohit <ro...@yahoo.com> on 2010/09/13 13:05:10 UTC
removing whitespace from String.
hi i am trying to remove whitespace from string, but have been unable to do
so in cases where there are 3 consecutive whitespaces. for eg.
String X = X.replaceAll(" ", "-");
replaces only a maximum of 2 consecutive whitespace and not 3. i tried
running the relaceAll, once again on the already modified string, but it did
not help.
any ideas will be helpful.
Thanks
Rohit
--
View this message in context: http://ofbiz.135035.n4.nabble.com/removing-whitespace-from-String-tp2537234p2537234.html
Sent from the OFBiz - User mailing list archive at Nabble.com.
Re: removing whitespace from String.
Posted by rohit <ro...@yahoo.com>.
hi Jacques,
Yes, i found the same code as you mentioned and it did work.
thanks so much.
rohit
--
View this message in context: http://ofbiz.135035.n4.nabble.com/removing-whitespace-from-String-tp2537234p2539014.html
Sent from the OFBiz - User mailing list archive at Nabble.com.
Re: removing whitespace from String.
Posted by Jacques Le Roux <ja...@les7arts.com>.
Not sure why it got so lovely packed :/
Jacques
From: "Jacques Le Roux" <ja...@les7arts.com>
> Did you find it?
> s.replaceAll("\\s+","");Always think regex in such cases: more powerfulJacques
> From: "Jacques Le Roux" <ja...@les7arts.com>
>> Did you try to Google for "java replace all spaces"?
>>
>> Jacques
>>
>> From: "rohit" <ro...@yahoo.com>
>>> hi i am trying to remove whitespace from string, but have been unable to do
>>> so in cases where there are 3 consecutive whitespaces. for eg.
>>>
>>> String X = X.replaceAll(" ", "-");
>>>
>>> replaces only a maximum of 2 consecutive whitespace and not 3. i tried
>>> running the relaceAll, once again on the already modified string, but it did
>>> not help.
>>>
>>> any ideas will be helpful.
>>>
>>> Thanks
>>>
>>> Rohit
>>>
>>> --
>>> View this message in context: http://ofbiz.135035.n4.nabble.com/removing-whitespace-from-String-tp2537234p2537234.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>
>>
>
Re: removing whitespace from String.
Posted by Jacques Le Roux <ja...@les7arts.com>.
Did you find it?
s.replaceAll("\\s+","");Always think regex in such cases: more powerfulJacques
From: "Jacques Le Roux" <ja...@les7arts.com>
> Did you try to Google for "java replace all spaces"?
>
> Jacques
>
> From: "rohit" <ro...@yahoo.com>
>> hi i am trying to remove whitespace from string, but have been unable to do
>> so in cases where there are 3 consecutive whitespaces. for eg.
>>
>> String X = X.replaceAll(" ", "-");
>>
>> replaces only a maximum of 2 consecutive whitespace and not 3. i tried
>> running the relaceAll, once again on the already modified string, but it did
>> not help.
>>
>> any ideas will be helpful.
>>
>> Thanks
>>
>> Rohit
>>
>> --
>> View this message in context: http://ofbiz.135035.n4.nabble.com/removing-whitespace-from-String-tp2537234p2537234.html
>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>
>
Re: removing whitespace from String.
Posted by Jacques Le Roux <ja...@les7arts.com>.
Did you try to Google for "java replace all spaces"?
Jacques
From: "rohit" <ro...@yahoo.com>
> hi i am trying to remove whitespace from string, but have been unable to do
> so in cases where there are 3 consecutive whitespaces. for eg.
>
> String X = X.replaceAll(" ", "-");
>
> replaces only a maximum of 2 consecutive whitespace and not 3. i tried
> running the relaceAll, once again on the already modified string, but it did
> not help.
>
> any ideas will be helpful.
>
> Thanks
>
> Rohit
>
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/removing-whitespace-from-String-tp2537234p2537234.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>