aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
authorMic Bowman2012-03-01 14:49:49 -0800
committerMic Bowman2012-03-01 14:49:49 -0800
commit8a375f3c30302c4a7ace1afb05a8b49fbb415640 (patch)
tree3bcdfe6f35daebd876f1d1e40ab6aaec330402c3 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation
parentMerge branch 'master' of /home/opensim/src/opensim (diff)
downloadopensim-SC-8a375f3c30302c4a7ace1afb05a8b49fbb415640.zip
opensim-SC-8a375f3c30302c4a7ace1afb05a8b49fbb415640.tar.gz
opensim-SC-8a375f3c30302c4a7ace1afb05a8b49fbb415640.tar.bz2
opensim-SC-8a375f3c30302c4a7ace1afb05a8b49fbb415640.tar.xz
Adds an OSSL command for regular expression-based string replacement. Parameters
are osReplaceString(string source, string patter, string replace, integer count, integer start) The count parameter specifies the total number of replacements to make, -1 makes all replacements.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index ff1f5fd..8edd146 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2160,6 +2160,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2160 return result; 2160 return result;
2161 } 2161 }
2162 2162
2163 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start)
2164 {
2165 CheckThreatLevel(ThreatLevel.High, "osReplaceString");
2166 m_host.AddScriptLPS(1);
2167
2168 // Normalize indices (if negative).
2169 // After normlaization they may still be
2170 // negative, but that is now relative to
2171 // the start, rather than the end, of the
2172 // sequence.
2173 if (start < 0)
2174 {
2175 start = src.Length + start;
2176 }
2177
2178 if (start < 0 || start >= src.Length)
2179 {
2180 return src;
2181 }
2182
2183 // Find matches beginning at start position
2184 Regex matcher = new Regex(pattern);
2185 return matcher.Replace(src,replace,count,start);
2186 }
2187
2163 public string osLoadedCreationDate() 2188 public string osLoadedCreationDate()
2164 { 2189 {
2165 CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate"); 2190 CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate");