Raised This Month: $ Target: $400
 0% 

Remove Line Breaks from String?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-01-2007 , 16:56   Remove Line Breaks from String?
Reply With Quote #1

Hmm, I've tried respectively \r, \r\n, and ^n, all of which did not work with replace_all().

What am I doing wrong?

Thanks .
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-01-2007 , 17:05   Re: Remove Line Breaks from String?
Reply With Quote #2

Maybe use this native:
Code:
replace ( text[], len, const what[], const with[] )
don't know if replace_all() does the same..0o


greetz regalis
__________________
regalis is offline
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 06-01-2007 , 17:06   Re: Remove Line Breaks from String?
Reply With Quote #3

replace_all is a replace() loop
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-01-2007 , 18:16   Re: Remove Line Breaks from String?
Reply With Quote #4

trim() works, but I wonder if it's possible to do it manually.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
_Master_
Senior Member
Join Date: Dec 2006
Old 06-02-2007 , 04:39   Re: Remove Line Breaks from String?
Reply With Quote #5

I think the indeces are wrong but...
Code:
if(text[0] == '\' || text[0] == '^') text[0] = 0
else{
	len = strlen(text)
	switch(text[len - 1]){
		case '^n': text[len - 1] = 0
		case '\n': text[len - 2] = 0
		case '\r': text[len - 1] = 0
	}
}

Last edited by _Master_; 06-02-2007 at 04:41.
_Master_ is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode