08-07-2021, 09:54 PM
(This post was last modified: 08-07-2021, 09:55 PM by boriel.
Edit Reason: Fixing code
)
(08-01-2021, 10:00 AM)RandomiserUsr Wrote: It would be handy to have a
LTRIM
RTRIM
TRIM
functions built in to ZXB
I know you could right one but I wonder if there is a faster way to be compiled?
thanks
Ok, I've implemented ltrim(s, subs), rtrim(s, subs) and trim(s, sub) which trim the string subs in the respective side of s.
They're in #include <string.bas> in this new version:
http://www.boriel.com/files/zxb/zxbasic-...ta1.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta1.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz
Please, try it and tell me
An example:
Code:
#include <string.bas>
print "'"; ltrim("", "a"); "'"
print "'"; ltrim("hello world", ""); "'"
print "'"; ltrim("hello world", "he"); "'"
print "'"; ltrim("hehello world", "he"); "'"
print "'"; ltrim("hehehe", "he"); "'"