Skip to content

llParseStringKeepNulls

list llParseStringKeepNulls(string Text, list Separators, list Spacers)

Breaks Text into a list, discarding separators, keeping spacers, keeping any null values generated. (separators and spacers must be lists of strings, maximum of 8 each).

llParseStringKeepNulls works almost exactly like llParseString2List, except that if a null is found it will add a null-string instead of discarding it like llParseString2List does.

Parameters
Text (string)
Separators (list)
Spacers (list)

The behavior is identical to llParseString2List, except blank strings found in the list are kept. This is useful when parsing a list that contains values that can be null or empty (and subsequently removing the nulls would upset the distribution of data and the element indexes).

For example: llParseStringKeepNulls("", ["~"], []) will return [""]

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,"><") + ">");
}
}
  • 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. The first match is the one that is returned. Using the list ["A", "AB"] will always act with “A” and never “AB”.
  • Duplicate or irrelevant separators or spacers count towards the limits and slow down parsing.
  • All entries in the return are typed as string. Use explicit typecasting 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).
  • Remember to capture the result of the operation with a variable, unless you are planning to act directly on the results.