llReplaceSubStringList for bulk replacing
Peter Stindberg
I often encounter situations where multiple subsequent calls of llReplaceSubString are required. This invokes many repetitive lines of code, eating away at script memory.
I would like to suggest a bulk function:
string llReplaceSubStringList( string src, list patterns, list replacement_patterns, integer count );
The two lists need to have the same number of entries (alternatively, a strided list could be used). When evoked, the function would loop through the lists and replace each item on the list with its corresponding item on the second list.
Example:
test = llReplaceSubStringList(test, ["$A", "$T", "$U"], ["Alphinaud", "Thancred", "Urianger"], 0);
This would reduce near-identical code massively!
Log In
Bavid Dailey
If the patterns and the replacement-patterns lists were not the same size, which can easily happen if the lists are constructed dynamically, it probably shouldn't be an error if second had more elements than the first.
Also , extra bonus if the patterns were regex patterns!