AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove Line Breaks from String? (https://forums.alliedmods.net/showthread.php?t=55901)

mysticssjgoku4 06-01-2007 16:56

Remove Line Breaks from String?
 
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 :).

regalis 06-01-2007 17:05

Re: Remove Line Breaks from String?
 
Maybe use this native:
Code:

replace ( text[], len, const what[], const with[] )
don't know if replace_all() does the same..0o


greetz regalis

P34nut 06-01-2007 17:06

Re: Remove Line Breaks from String?
 
replace_all is a replace() loop

mysticssjgoku4 06-01-2007 18:16

Re: Remove Line Breaks from String?
 
trim() works, but I wonder if it's possible to do it manually.

_Master_ 06-02-2007 04:39

Re: Remove Line Breaks from String?
 
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
        }
}



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

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