Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
10-10-2004 11:42
Dunno if anybody will find this useful. I certainly do  . This is a trim() function to clear whitespaces off the beginning and end of a string. Usefull if you're parsing a lot of user input. Not very complicated so a lot of you have probably done something similar. Anyway, have at it  . string trim(string str) { return llDumpList2String(llParseString2List(str, [" "], []), " "); }
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
10-14-2004 15:39
Here's another handly little blip. string str_replace(string source, string test, string replace) { list list_source = llParseString2List(source, [], [test]);
integer i; string return_str = ""; for (i = 0; i < llGetListLength(list_source); i += 1) { if (llList2String(list_source, i) == test) { return_str += replace; } else { return_str += llList2String(list_source, i); } }
return return_str; }
|