5 pattern matching, Pattern, Pattern matching – KEYENCE SR-700 Series User Manual
Page 7
7
E SR SCRIPT RM
3-5
Pattern matching
This section describes how to search character strings with specific patterns
(Pattern matching) from character strings.
Pattern
Patterns used to search alphabets, numbers, symbols, etc. from character strings.
Meta-character
*1 Specify characters other than alphanumeric characters
Quantifier
Range specification
* If ^ (caret) is added to the beginning of the pattern, the match is fixed to the
beginning of the target character string.
If $ (dollar) is added to the end of the pattern, the match is fixed to the end of the
target character string.
Pattern
Meaning
.
All characters (arbitrary 1 character)
%a
Character
%c
Control character (0x01 to 0x1F, 0x7F)
%d
Number
%l
Alphabet lowercase
%p
Symbol (! " # $ % & ' ( ) * + , - . / : ; > = < ? @ [ \ ] ^ _ ` { | })
%s
Space character (0x09,0x0a,0x0b,0x0c,0x0d,0x20)
%u
Alphabet uppercase
%w
Alphabet and number
%x
Hexadecimal number (0 to 9, a to f, A to F)
%z
null character
% character
*1
Literal character
Pattern
Meaning
+
Matches with 1 or more times repetitions of the previous character.
∗
Matches with 0 or more times repetitions of the previous character.
(Longest match)
-
Matches with 0 or more times repetitions of the previous character.
(Shortest match)
?
Matches with 0 or 1 time repetition of the previous character.
Pattern
Meaning
[0-9]
Number (0 to 9)
[^0-9]
Not number (0 to 9)
[a-z]
Alphabet lowercase (a to z)
[A-Z]
Alphabet uppercase (A to Z)
[a-zA-Z]
Alphabet lowercase and alphabet uppercase (a to z and A to Z)
[0-9a-zA-Z]
Number and alphabet (0 to 9, a to z and A to Z)