public LSL_List osMatchString(string src, string pattern, int start)
{
CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString");
m_host.AddScriptLPS(1);
LSL_List result = new LSL_List();
// Normalize indices (if negative).
// After normlaization they may still be
// negative, but that is now relative to
// the start, rather than the end, of the
// sequence.
if (start < 0)
{
start = src.Length + start;
}
if (start < 0 || start >= src.Length)
{
return result; // empty list
}
// Find matches beginning at start position
Regex matcher = new Regex(pattern);
Match match = matcher.Match(src, start);
while (match.Success)
{
foreach (System.Text.RegularExpressions.Group g in match.Groups)
{
if (g.Success)
{
result.Add(new LSL_String(g.Value));
result.Add(new LSL_Integer(g.Index));
}
}
match = match.NextMatch();
}
return result;
}