E.2 How to specify regular expressions
The following table describes how to specify regular expressions.
Specification method |
Description |
---|---|
character-string |
Match a line that contains the specified character string. |
^character-string |
Match a line that begins with the specified character string. |
character-string$ |
Match a line that ends with the specified character string. |
^character-string$ |
Combines ^ and $ to match a line that consists only of the specified character string. |
^$ |
Combines ^ and $ to match a null line. |
. (period) |
Match any one character. |
character* |
Match a character string in which the character immediately preceding * is included any number of times or no times. |
.* |
Combines . (period) and * to match any character string. |
character+ |
Match a character string in which the character immediately preceding + is included at least once. |
character? |
Match a character string in which the character immediately preceding ? is included once or not at all. |
regular-expression|regular-expression |
Match either of the regular expressions separated by the | character. |
(regular-expressions) |
Groups regular expressions. This method is used mainly in conjunction with the | character. |
character{n} |
Match a character string in which the character immediately preceding {n} is included n times. |
character{n,} |
Match a character string in which the character immediately preceding {n,} is included at least n times. |
character{n,m} |
Match a character string in which the character immediately preceding {n,m} is included at least n times but no more than m times. |
[character-string] |
Match any of the characters in the character string specified in [ ]. |
[^character-string] |
Match any character that is not one of the characters in the character string specified in [ ]. |
[character-character] |
Match any character that is within the specified range of character codes (when sorted in ascending order). |
[^character-character] |
Match any character that is not within the specified range of character codes (when sorted in ascending order). |
\special-character |
Handle the specified special character as a normal character. |