OsRegexIsMatch
From OpenSimulator
(Difference between revisions)
(Add exemple) |
|||
| Line 5: | Line 5: | ||
|delay=0 | |delay=0 | ||
|description=Returns 1 if the input string matches the regular expression pattern. Wraps to Regex.IsMatch() | |description=Returns 1 if the input string matches the regular expression pattern. Wraps to Regex.IsMatch() | ||
| + | |ossl_example=<source lang = "lsl"> | ||
| + | // | ||
| + | // osRegexIsMatch Script Example | ||
| + | // Author: djphil | ||
| + | // | ||
| + | |||
| + | string check_string(string input, string pattern) | ||
| + | { | ||
| + | if (osRegexIsMatch(input, pattern)) | ||
| + | { | ||
| + | return "The input string \"" + input + "\" matches with the regular expression pattern \"" + pattern + "\""; | ||
| + | } | ||
| + | |||
| + | else | ||
| + | { | ||
| + | return "The Input string \"" + input + "\" do not matches with the regular expression pattern \"" + pattern + "\""; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | default | ||
| + | { | ||
| + | state_entry() | ||
| + | { | ||
| + | llSay(PUBLIC_CHANNEL, "Touch to see osRegexIsMatch usage."); | ||
| + | } | ||
| + | |||
| + | touch_start(integer number) | ||
| + | { | ||
| + | // Check lowercase from A to Z | ||
| + | llSay(PUBLIC_CHANNEL, check_string("abcdef", "[a-z]")); | ||
| + | llSay(PUBLIC_CHANNEL, check_string("ABCDEF", "[a-z]")); | ||
| + | llSay(PUBLIC_CHANNEL, check_string("123456", "[a-z]")); | ||
| + | |||
| + | // Check uppercase | ||
| + | llSay(PUBLIC_CHANNEL, check_string("abcdef", "[A-Z]")); | ||
| + | llSay(PUBLIC_CHANNEL, check_string("ABCDEF", "[A-Z]")); | ||
| + | llSay(PUBLIC_CHANNEL, check_string("123456", "[A-Z]")); | ||
| + | |||
| + | // Check numbers from 0 to 9 | ||
| + | llSay(PUBLIC_CHANNEL, check_string("abcdef", "[0-9]")); | ||
| + | llSay(PUBLIC_CHANNEL, check_string("ABCDEF", "[0-9]")); | ||
| + | llSay(PUBLIC_CHANNEL, check_string("123456", "[0-9]")); | ||
| + | } | ||
| + | } | ||
| + | </source> | ||
|additional_info=This function was added in 0.7.5-post-fixes | |additional_info=This function was added in 0.7.5-post-fixes | ||
}} | }} | ||
Revision as of 11:01, 26 November 2020
integer osRegexIsMatch(string input, string pattern)
| |
| Returns 1 if the input string matches the regular expression pattern. Wraps to Regex.IsMatch() | |
| Threat Level | Low |
| Permissions | Use of this function is always allowed by default |
| Extra Delay | 0 seconds |
| Example(s) | |
// // osRegexIsMatch Script Example // Author: djphil // string check_string(string input, string pattern) { if (osRegexIsMatch(input, pattern)) { return "The input string \"" + input + "\" matches with the regular expression pattern \"" + pattern + "\""; } else { return "The Input string \"" + input + "\" do not matches with the regular expression pattern \"" + pattern + "\""; } } default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osRegexIsMatch usage."); } touch_start(integer number) { // Check lowercase from A to Z llSay(PUBLIC_CHANNEL, check_string("abcdef", "[a-z]")); llSay(PUBLIC_CHANNEL, check_string("ABCDEF", "[a-z]")); llSay(PUBLIC_CHANNEL, check_string("123456", "[a-z]")); // Check uppercase llSay(PUBLIC_CHANNEL, check_string("abcdef", "[A-Z]")); llSay(PUBLIC_CHANNEL, check_string("ABCDEF", "[A-Z]")); llSay(PUBLIC_CHANNEL, check_string("123456", "[A-Z]")); // Check numbers from 0 to 9 llSay(PUBLIC_CHANNEL, check_string("abcdef", "[0-9]")); llSay(PUBLIC_CHANNEL, check_string("ABCDEF", "[0-9]")); llSay(PUBLIC_CHANNEL, check_string("123456", "[0-9]")); } } | |
| Notes | |
| This function was added in 0.7.5-post-fixes | |