Syntax

list llParseStringKeepNulls( string src, list separators, list spacers );

Forced delay: 0.0 seconds. Energy: 10.0.

Parameters

string src
source string
list separators
separators to be discarded
list spacers
spacers to be kept

Return value

Returns a list that is src broken into a list, discarding separators, keeping spacers, keeping any null values generated.

Specification

The behavior is identical to that for 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).

llParseStringKeepNulls("", ["~"], []) will return [""]

Caveats

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

Replacement functions without or very large separator/spacer count limits

ParseString2ListFunctions exactly the same as llParseString2List and llParseStringKeepNulls.
separateWordsFunctions the same as llParseString2List unless certain preconditions are not met.

See also

Functions