Core Function CSetMatch
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> CSetMatch( <expression>, <charset>, <case> ) </pre> === Description === Check if a string contains only characters from a substring(charset). === Parameters === ==== ex...") |
(→Return Value) |
||
(4 intermediate revisions by one user not shown) | |||
Line 25: | Line 25: | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns | + | Success: Returns true. |
− | Failure: Returns | + | Failure: Returns false. |
=== Remarks === | === Remarks === | ||
Line 36: | Line 36: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $cset = 'A'..'F' . 'a'..'f' . '0'..'9'; | + | $cset = ('A'..'F') . ('a'..'f') . ('0'..'9'); |
$str = "411C88"; | $str = "411C88"; | ||
Line 48: | Line 48: | ||
// Check if the string your standard ASCII | // Check if the string your standard ASCII | ||
$str = "The quick brown fox"; | $str = "The quick brown fox"; | ||
− | MsgBox( | + | MsgBox( "First: " . CSetMatch($str, @Printable) ); |
// Check if the string is Japanese Hiragana | // Check if the string is Japanese Hiragana | ||
$str = "こんにちわ"; | $str = "こんにちわ"; | ||
− | MsgBox( | + | MsgBox( "Second: " . CSetMatch($str, @Hiragana) ); |
</syntaxhighlight> | </syntaxhighlight> | ||
Go [[Macros|here]] for a complete list of character set macros. | Go [[Macros|here]] for a complete list of character set macros. |
Latest revision as of 16:13, 20 June 2015
CSetMatch( <expression>, <charset>, <case> )
Contents |
Description
Check if a string contains only characters from a substring(charset).
Parameters
expression
The string to check.
charset
A string of chars to compare.
case
Optional; If this param exists the match will be case insensitive regardless of what you place in this param.
Default is case sensitive.
Return Value
Success: Returns true.
Failure: Returns false.
Remarks
None.
Example
$cset = ('A'..'F') . ('a'..'f') . ('0'..'9'); $str = "411C88"; MsgBox( CSetMatch($str, $cset) ); MsgBox( CSetMatch($str, $cset, 1) ); // Case insensitive
Examples of using this with character set macro
// Check if the string your standard ASCII $str = "The quick brown fox"; MsgBox( "First: " . CSetMatch($str, @Printable) ); // Check if the string is Japanese Hiragana $str = "こんにちわ"; MsgBox( "Second: " . CSetMatch($str, @Hiragana) );
Go here for a complete list of character set macros.