From Second Life Wiki
ParseString2List
llParseString2List
Function: list llParseString2List( string src, list separators, list spacers );
Returns a list that is src broken into a list of strings, discarding separators, keeping spacers, discards any null values generated.
| • string
| src
| –
| source string
|
|
| • list
| separators
| –
| separators to be discarded
|
|
| • list
| spacers
| –
| spacers to be kept
|
|
Caveats
- Only the first 8 separators and first 8 spacers will be used any extras will be ignored.
- All separators and spacers must be strings, all other types will be ignored.
- Separators take precedent over spacers. The string is parsed from start to finish, each position is compared against the separators then spacers before moving onto the next position.
- Duplicates are ignored.
- All entries in the return are typed as string. Use explicit typecasting on llList2String to convert the values into other types. Do not rely upon the implicit typecasting of the other llList2* functions (as they typically return a default value).
Examples
default
{
state_entry()
{
// This will say:
// <A><crazy><fox><.><Saw><the><moon><.><.>
string my_string = "A crazy fox. Saw the moon..";
list my_list = llParseString2List(my_string,[" "],["."]);
llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
// This will say:
// <A><crazy><fox><.><><><Saw><the><moon><.><><.><>
my_list = llParseStringKeepNulls(my_string,[" "],["."]);
llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
}
}
Useful Snippets
Examples of processing more than 8 spacers or separators: