Mikroelektronika MIKROE-724 データシート

ページ / 726
110
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Metacharacters - Predefined classes
 
\w
 - an alphanumeric character (including 
"_"
 
\W
 - a nonalphanumeric character 
 
\d
 - a numeric character 
 
\D
 - a non-numeric character 
 
\s
 - any space (same as [
\t\n\r\f
]) 
 
\S
 - a non space 
You may use
 \w
\d
 and
 \s
 within custom character classes.
Example
 
routi\de
 - matches strings like 
'routi1e'
'routi6e'
 and so on, but not 
'routine'
'routime'
 and 
so on. 
Metacharacters - Word boundaries
A word boundary (
"\b"
) is a spot between two characters that has an alphanumeric character (
"\w"
) on one side, 
and a nonalphanumeric character (
"\W"
) on the other side (in either order), counting the imaginary characters off the 
beginning and end of the string as matching a 
"\W"
 
\b
 - match a word boundary) 
 
\B
 - match a non-(word boundary) 
Metacharacters - Iterators
Any  item  of  a  regular  expression  may  be  followed  by  another  type  of  metacharacters  -  iterators.  Using  this 
metacharacters,you can specify number of occurences of previous character, metacharacter or subexpression. 
 
*
 - zero or more (“greedy”), similar to {0,} 
 
+
 - one or more (“greedy”), similar to {1,} 
 
?
 - zero or one (“greedy”), similar to {0,1} 
 
{n}
 - exactly n times (“greedy”) 
 
{n,}
 - at least n times (“greedy”) 
 
{n,m}
 - at least n but not more than m times (“greedy”) 
 
*?
 - zero or more (“non-greedy”), similar to {0,}? 
 
+?
 - one or more (“non-greedy”), similar to {1,}? 
 
??
 - zero or one (“non-greedy”), similar to {0,1}? 
 
{n}?
 - exactly n times (“non-greedy”) 
 
{n,}?
 - at least n times (“non-greedy”) 
 
{n,m}?
 - at least n but not more than m times (“non-greedy”) 
So, digits in curly brackets of the form, 
{n,m}
, specify the minimum number of times to match the item 
n
 and the 
maximum 
m
. The form 
{n}
 is equivalent to 
{n,n}
 and matches exactly 
n
 times. The form 
{n,}
 matches 
n
 or more 
times. There is no limit to the size of 
n
 or 
m
, but large numbers will chew up more memory and slow down execution.
If a curly bracket occurs in any other context, it is treated as a regular character.