Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

scripting help needed: remove characters from string

Lance Corrimal
I don't do stupid.
Join date: 9 Jun 2006
Posts: 877
03-02-2009 14:46
hi,

i have two strings, how do i strip all characters from string A that are NOT in string B?

any tips?

thanks,
LC
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
03-02-2009 15:15
That's an exercise in applying string functions:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=string
_____________________
From Studio Dora
Mercurion Curtiss
Registered User
Join date: 6 Oct 2006
Posts: 8
03-28-2009 23:14
im have a similar enigma here as well. Trying to omit dashes in a key id. Is there a workaround for this?

I didn't quite see anything on the lslwiki. Any help will do thanks!
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
03-28-2009 23:39
AFAIK, there is no magic for your string problem. You'll have to extract each letter from your string and check if they are valid or not.

For the stripped key, there's a simple trick:

string stripped = (string)llParseString2List((string)id, ["-"], []);
Mercurion Curtiss
Registered User
Join date: 6 Oct 2006
Posts: 8
03-28-2009 23:49
awesome! I was fiddling with all the string functions in loops but never thought of casting a list! thanks!!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-29-2009 02:08
CODE

integer counter = llListLength( a );
while (counter){
--counter;
if (!~llSubStringIndex( b, llGetSubString( a, counter, counter ) )){
a = llDeleteSubString( a, counter, counter );
}
}

might want to use llToLower (or Upper) to make sure you don't catch x when only X appears in string b
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -