QMMatch()

QMMatch()

Top  Previous  Next

 

The QMMatch() function matches a string against a pattern template. It is analogous to the QMBasic MATCHES operator.

 

 

The function arguments are:

 

Srcis the string to be processed.

 

Patternis the pattern template to be used.

 

 

The QMMatch() function tests whether Src matches the Pattern template consisting of one or more concatenated items from the following list.

 

...Zero or more characters of any type
0XZero or more characters of any type
nXExactly n characters of any type
n-mXBetween n and m characters of any type
0AZero or more alphabetic characters
nAExactly n alphabetic characters
n-mABetween n and m alphabetic characters
0NZero or more numeric characters
nNExactly n numeric characters
n-mNBetween n and m numeric characters
"string"A literal string which must match exactly. Either single or double quotation marks may be used.

 

The values n and m are integers with any number of digits. m must be greater than or equal to n.

 

The 0A, nA, 0N, nN and "string" patterns may be preceded by a tilde (~) to invert the match condition. For example, ~4N matches four non-numeric characters such as ABCD (not a string which is not four numeric characters such as 12C4).

 

A null string matches patterns ..., 0A, 0X, 0N, their inverses (~0A, etc) and "".

 

The 0X and n-mX patterns match against as few characters as necessary before control passes to the next pattern. For example, the string ABC123DEF matched against the pattern 0X2N0X matches the pattern components as ABC, 12 and 3DEF.

 

The 0N, n-mN, 0A, and n-mA patterns match against as many characters as possible. For example, the string ABC123DEF matched against the pattern 0X2-3N0X matches the pattern components as ABC, 123 and DEF.

 

The pattern string may contain alternative templates separated by value marks. The QMMatch() function tries each template in turn until one is a successful match against the string.

 

This function is evaluated on the client system and does not require a server connection to be open.

 

The examples below test whether the contents of PartCode is formed from between two and four letters followed by three digits, returning OK as a True/False value.

 

 

hmtoggle_plus1C

 

hmtoggle_plus1VB.Net

 

hmtoggle_plus1QMBasic Class Module

 

hmtoggle_plus1Java

 

hmtoggle_plus1Python