Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
REGULAR EXPRESSIONS
Introduction
Regular Expressions are a widely-used method of specifying patterns of text to
search for. Special metacharacters allow you to specify, for instance, that a particu-
lar string you are looking for, occurs at the beginning, or end of a line, or contains 
n
recurrences of a certain character. 
Simple matches
Any single character matches itself, unless it is a metacharacter with a special
meaning described below. A series of characters matches that series of characters
in the target string, so the pattern 
"short"
would match 
"short"
in the target string.
You can cause characters that normally function as metacharacters or escape
sequences to be interpreted by preceding them with a backslash 
"\"
For instance, metacharacter
"^"
matches beginning of string, but 
"\^"
matches
character 
"^"
, and 
"\\"
matches 
"\"
, etc. 
Examples : 
unsigned
matches string
'
unsigned
\^
unsigned
matches string
'^
unsigned
Escape sequences
Characters may be specified using a escape sequences: 
"
\n"
matches a newline,
"\t"
a tab, etc. More generally, 
\xnn
, where 
nn
is a string of hexadecimal digits,
matches the character whose ASCII value is
nn
If you need wide (Unicode) character code, you can use 
'
\x{nnnn}'
, where 
'
nnnn'
- one or more hexadecimal digits.
\xnn
- char with hex code 
nn
\x{nnnn)
- char with hex code 
nnnn
(one byte for plain text and two bytes for Unicode) 
\t
- tab (HT/TAB), same as 
\x09
\n
- newline (NL), same as 
\x0a
\r
- car.return (CR), same as 
\x0d
\f
- form feed (FF), same as 
\x0c
\a
- alarm (bell) (BEL), same as
\x07
\e
- escape (ESC) , same as 
\x1b
Examples: 
unsigned\x20int
matches 
'
unsigned int'
(note space in the middle)
\tunsigned
matches
'
unsigned'
(predecessed by tab) 
67
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Environment
mikroPASCAL PRO for AVR
CHAPTER 2