OsReplaceString

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "{{osslfunc |function_syntax=LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) |threat_level=VeryLow |description=This function is for r...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{osslfunc
 
{{osslfunc
|function_syntax=LSL_String osReplaceString(string src, string pattern, string replace, int count, int start)
+
|function_syntax=string osReplaceString(string src, string pattern, string replace, integer count, integer start)
 
|threat_level=VeryLow
 
|threat_level=VeryLow
 +
|permissions=true
 +
|delay=0
 
|description=This function is for regular expression-based string replacement. The count parameter specifies the total number of replacements to make where -1 makes all possible replacements.
 
|description=This function is for regular expression-based string replacement. The count parameter specifies the total number of replacements to make where -1 makes all possible replacements.
 +
|ossl_example=<source lang="lsl">
 +
//
 +
// osReplaceString usage example
 +
//
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        //Define an example text
 +
        string example_text = "ThX big rXd fox jumpXd ovXr thX lazy dog";
 +
       
 +
        // Show the owner the string before it's changed
 +
        llOwnerSay("Before : ''"+example_text+"''");
 +
       
 +
        // Replace all the upper case X-es with the lower case letter e
 +
        example_text = osReplaceString(example_text, "X", "e", -1, 0);
 +
       
 +
        // Show the owner the string after it's changed
 +
        llOwnerSay("After : ''"+example_text+"''");       
 +
    }
 +
}
 +
</source>
 +
|additional_info=This function was added in 0.7.4-post-fixes
 
}}
 
}}

Latest revision as of 14:41, 27 November 2018

string osReplaceString(string src, string pattern, string replace, integer count, integer start)
This function is for regular expression-based string replacement. The count parameter specifies the total number of replacements to make where -1 makes all possible replacements.
Threat Level VeryLow
Permissions Use of this function is always allowed by default
Extra Delay 0 seconds
Example(s)
//
// osReplaceString usage example
//
 
default
{
    state_entry()
    {
        //Define an example text
        string example_text = "ThX big rXd fox jumpXd ovXr thX lazy dog";
 
        // Show the owner the string before it's changed
        llOwnerSay("Before : ''"+example_text+"''");
 
        // Replace all the upper case X-es with the lower case letter e
        example_text = osReplaceString(example_text, "X", "e", -1, 0);
 
        // Show the owner the string after it's changed
        llOwnerSay("After : ''"+example_text+"''");        
    }
}
Notes
This function was added in 0.7.4-post-fixes
Personal tools
General
About This Wiki