SA-MP Forums Archive
Removing spaces at the end of a string - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Removing spaces at the end of a string (/showthread.php?tid=579050)



Removing spaces at the end of a string - Neos07 - 24.06.2015

Hello, I want to make this:
Quote:

"Hello! " ===> "Hello!"

I tried to do it by myself so this is the result and it doesn't work:
Quote:

new pos = strlen(thestring);
while(thestring[pos] == ' '){pos--;}
strdel(thestring, pos, strlen(text));




Re : Removing spaces at the end of a string - KillerDVX - 24.06.2015

Check this out buddy : http://forum.sa-mp.com/showthread.ph...t=slice+string

KillerDVX,



Re: Removing spaces at the end of a string - Neos07 - 24.06.2015

Thank you KillerDVX,
So I have to use strtrim:
Quote:

new string[128] = " XXbla blaY ";

strtrim(string); // string = "XXbla blaY"
strtrim(string, "XY"); // string = "bla bla"

string = "/Users/home/bla/bla/";

strtrim(string, "/\\", .edges = trim_right); // string = "/Users/home/bla/bla"




Re : Removing spaces at the end of a string - KillerDVX - 24.06.2015

Exactly ! ^^

Good luck buddy ! :3

KillerDVX,



Re: Removing spaces at the end of a string - Neos07 - 24.06.2015

Merci! :v


Re : Removing spaces at the end of a string - KillerDVX - 24.06.2015

FR : De rien !

ENG : Your welcome !

KillerDVX,