Mikroelektronika MIKROE-442 데이터 시트
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
109
Examples:
count[aeiou]r
finds strings
'countar'
,
'counter'
, etc. but not
'countbr'
,
'countcr'
, etc.
count[^aeiou]r
finds strings
'countbr'
,
'countcr'
, etc. but not
'countar'
,
'counter'
, etc.
Within a list, the
"-"
character is used to specify a range, so that
a-z
represents all characters between
"a"
and
"z"
,
inclusive.
If you want
"-"
itself to be a member of a class, put it at the start or end of the list, or precede it with a backslash.
If you want
']'
, you may place it at the start of list or precede it with a backslash.
Examples:
[-az]
matches
'a'
,
'z'
and
'-'
[az-]
matches
'a'
,
'z'
and
'-'
[a\-z]
matches
'a'
,
'z'
and
'-'
[a-z]
matches all twenty six small characters from
'a'
to
'z'
[\n-\x0D]
matches any of
#10,#11,#12,#13
.
[\d-t]
matches any digit,
'-'
or
't'
.
[]-a]
matches any char from
']'
..
'a'
.
Metacharacters
Metacharacters are special characters which are the essence of regular expressions. There are different types of
metacharacters, described below.
Metacharacters - Line separators
^
- start of line
$
- end of line
\A
- start of text
\Z
- end of text
.
- any character in line
Examples:
^PORTA
- matches string ‘
PORTA
‘ only if it’s at the beginning of line
PORTA$
- matches string ‘
PORTA
‘ only if it’s at the end of line
^PORTA$
- matches string ‘
PORTA
‘ only if it’s the only string in line
PORT.r
- matches strings like ‘
PORTA
’, ‘
PORTB
’, ‘
PORT1
’ and so on
The
“^”
metacharacter by default is only guaranteed to match beginning of the input string/text, and the
“$”
metacharacter only at the end. Embedded line separators will not be matched by
^”
or
“$”
.
You may, however, wish to treat a string as a multi-line buffer, such that the
“^”
will match after any line separator within
the string, and
“$”
will match before any line separator.
Regular expressions works with line separators as recommended at http://www.unicode.org/unicode/reports/tr18/