OsReplaceString: Difference between revisions

From OpenSimulator
Jump to navigationJump to search
imported>Kcozens
m Added permissions and delay information
imported>Kcozens
m Added note stating which version of OpenSim introduced this function
Line 28: Line 28:
}
}
</source>
</source>
|additional_info=This function was added in 0.7.4-post-fixes
}}
}}

Revision as of 16:38, 15 October 2018

LSL_String osReplaceString(string src, string pattern, string replace, int count, int 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