Add string llSubString2List(string src, string start_pattern, string end_pattern, string separator)
Woolfyy Resident
to have a much more powerful extraction tool based on tagged fields from any substring with patterns limits and not positions needing to be calculated as in llGetSubString() or basical conversions as in llCSV2List()
example :
string s = "comments mixed with fields and any stuff [[ field_1, field_2, field_3 ]] blabla";
list l = llSubString2List( s, "[[", "]]", "," );
will result in list l = [ filed_1, field_2, field_3 ]
i-e easy tool to extract data from user input or notecards or any text fields in prims etc.
Log In
Lucia Nightfire
Just use Linkset Data and regex.
Woolfyy Resident
Lucia Nightfire Thanks for your proposal but linkset data is a pure loss of time and not usable when you use for example prims title or comments as text fields ...
Bavid Dailey
I offer an alternative method of string handling which I use a lot in parsing
string decat(string source, string target, integer combo, integer trimType)
{
if (combo == 0x0)
return "";
string result = "";
if (combo == 0x7)
result = source;
else
{
integer sourceLen = llStringLength(source);
integer ixTarget = llSubStringIndex(source, target);
if (combo & 0x4)
if (ixTarget > 0)
result += llGetSubString(source, 0, ixTarget-1);
else if (ixTarget < 0)
result += source;
if (combo & 0x2)
if (ixTarget >= 0)
result += target;
if (combo & 0x1)
if (ixTarget >= 0)
{
ixTarget = ixTarget+llStringLength(target);
if (ixTarget < sourceLen)
result += llGetSubString(source, ixTarget, sourceLen-1);
}
}
if (trimType == 0)
return result;
return llStringTrim(result, trimType);
}
Woolfyy Resident
Bavid Dailey Hello i have tens of different ways to parse my data collection.
My proposal here is to make a super simple function, but as mentioned by Lucia Nightfire one more idea could also be to extend regex use not just to linkset data.
Anyway integrated functions are always more efficient than tens of lines of code.