The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 remove whitespace in string

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
havermann Posted - 08/14/2009 : 08:38:43 AM
Origin Ver.7.0SR2 XP

I have several strings with tons of different whitespace (tabs and blanks). Is there an easy way to remove all whitespace from a string? I tried "TrimLeft" and "remove" without success.

Thanks a lot

BR
Havermann

Regards
Gert
4   L A T E S T    R E P L I E S    (Newest First)
havermann Posted - 08/20/2009 : 05:09:38 AM
Thank you both, Remove works fine.

BR
Gert

Regards
Gert
Iris_Bai Posted - 08/17/2009 : 9:34:56 PM
Yes, CP is correct, should use String::Remove.

Iris
cpyang Posted - 08/17/2009 : 07:29:59 AM
why not just


str.Remove(' ');
str.Remove('\t');


CP
Iris_Bai Posted - 08/16/2009 : 10:32:15 PM
Hi,

Please see the following example:

void remove_whitespace(string str = "ab\tc d e f   g")
{
	str.Replace('\t', ' '); // replace all tabs with black
	
	vector<string> vs;
	str.GetTokens(vs, ' '); // get each token seperated by black 
	
	// append sub string from vs to one string
	string strTemp;
	for(int nn = 0; nn < vs.GetSize(); nn++)
		strTemp += (vs[nn]);
	
	str = strTemp;
	out_str(str);
}


Iris

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000