System Functions
MSK( ) Scan String for Mask
 
Format MSK(string$,mask$[,ERR=stmtref])
 
Where:
 
mask$ String containing the pattern / mask definition. If this value is null, then the previously used pattern is reused. String expression.
 
stmtref Program line number or statement label to which to transfer control.
 
string$ String to search. Maximum string size 8kb.
 
Returns Integer reporting starting offset.
 
Description Use the MSK( ) function to scan a string looking for a specific pattern of characters. The value returned is an integer reporting the starting offset of the longest string matching the given mask or pattern. The pattern defines the mask as a regular expression or series of characters, some of which have a special meaning. The following table lists those characters and their meanings. Combinations are allowed.
 
Mask Character. Format in Pattern$ Search
 
^ Caret At start of regular To find a match with the start of the
expression. string being searched.
 
$ Dollar Sign$ At end of regular To find a match with the end of the
  expression. string being searched.
. Period To find a match with any character
 
String of characters To define a sub-expression to match.
( string ) (or other codes) enclosed in parentheses.
 
[ string ] String enclosed in To find a match with any character in
square brackets that string.
 
Square bracketing To find a match with any character
  combined with a except the characters in the string; e.g.,
  [^string] caret ^ as the first [xyz] matches x, y,or z, while
  character of the [^xyz] matches a, b, c, but not
string. x, y, or z.
 
Dash 2 characters To specify a range.
separated by dash.
 
  Combination of dash To form expressions: e.g., [a-bd-z] to
  [str–ing] within string in search for a match with any lower case
square brackets. letter except c.
 
Mask Character. Format in Pattern$ Search
 
  To search for zero or more occurrences of
  At the end of a the character (or sub-expression);e.g., in
* Asterisk character (or fo*, the *operates on the o; it
sub-expression). matches f, fo, foo etc.. but doesn't match fa. The expression f(at)* matches f, fat, fatat, fatatat, etc.
 
  At the end of a To find a match with 1 or more
  + Plus Sign character (or occurrences of that character (or
sub-expression). sub-expression); e.g., fa+ matches
fa, faa, faaa, etc. but not f.
 
  At the end of a To indicate that it is optional. For
? Question Mark character (or example, colou?r matches color or
  colour and sea(horse)? matches
sub-expression). sea or seahorse.
 
  Separating two To find a match for either of the two
| Vertical Bar characters (or characters (or sub-expressions); e.g.,
  c(at)|(ow) matches cat or cow and
sub-expressions). at|(nd) matches at or and.
 
  To indicate that the character that
\ Backslash Preceding a mask
character. follows is to be taken literally; e.g., to search for multiple asterisks use \**.
 
The MSK( ) function returns the starting offset in the search string$ (where it matches the pattern specified). The MSL system variable and TCB(16) return the length of the string found.


*Note* When the 'TL' (Thoroughbred LIKE) system parameter is OFF, the LIKE operator uses the same pattern matching that MSK( ) does. With the 'OM' (Old Mask) System Parameter ON, MSK( ) behaviour is compatible with the UNIX GREP command.


 
See Also MSL System Variable
TCB( ) Return Task Information
'TL' System Parameter,
'OM' System Parameter.
Operators
 
Example ->PRINT MSK("my name is Foxxy","[A-Z][a-z]*"),MSL
12 5
 
Here, MSK( ) reports the starting offset. (F, the 12th character, is the first uppercase character.) MSL( ) reports the length of the string. (Foxxy is 5 characters long.)