deltreey icon

nwscript SplitString

deltreey | PRO | 10/14/23 04:07:35 PM UTC (Edited) | 0 ⭐ | 10909 👁️ | Never ⏰ | [NWN:EE]
C++ |

680 B

|

Gaming

|

0 👍

/

0 👎

json SplitString(string fullstring, string substring)
{
    json result = JsonArray();
 
    int index = FindSubString(fullstring, substring);
    while (index > -1)
    {
        result = JsonArrayInsert(result, JsonString(GetSubString(fullstring, 0, index)));
        // if this is too high, it's ok, it just goes to the end of the string
        int stringLength = GetStringLength(fullstring);
        fullstring = GetSubString(fullstring, index + GetStringLength(substring), stringLength);
        index = FindSubString(fullstring, substring);
    }
    result = JsonArrayInsert(result, JsonString(fullstring)); // include all to the end of the string
 
    return result;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎