G.3 Comparison between types of regular expressions
The following table describes the differences in the types of regular expressions that can be used in Windows and other operating systems.
Expression |
Meaning |
Windows |
Linux |
||
---|---|---|---|---|---|
JP1 |
Extd XPG4 |
Basic POSIX |
Extd POSIX |
||
String |
Matches lines containing the specified string. |
Y |
Y |
Y |
Y |
^string |
Matches the specified string at the beginning of a line. |
Y |
Y |
Y |
Y |
string$ |
Matches the specified string at the end of a line. |
Y |
Y |
Y |
Y |
^string$ |
Combination of ^ and $. Matches lines containing only the specified string. |
Y |
Y |
Y |
Y |
^$ |
Combination of ^ and $. Matches empty lines. |
Y |
Y |
Y |
Y |
. (period) |
Matches any single character. |
Y |
Y |
Y |
Y |
char* |
Matches strings of zero or more occurrences of the preceding character. |
Y |
Y |
Y |
Y |
.* |
Combination of a period (.) and asterisk (*). Matches any character string. |
Y |
Y |
Y |
Y |
char+ |
Matches strings of one or more occurrences of the preceding character. |
N |
Y |
N |
Y |
char? |
Matches strings of zero or one occurrence of the preceding character. |
N |
Y |
N |
Y |
regex|regex |
Matches either regular expression. |
N |
Y |
N |
Y |
(regex) |
Groups a regular expression. Used to explicitly indicate to the program that the specified characters are a regular expression. Used mainly with a vertical bar (|). (See G.4 Tips on using regular expressions.) |
N |
Y |
N |
Y |
char{n} |
Matches strings in which the preceding character occurs n times. |
N |
Y |
N |
Y |
char{n,} |
Matches strings in which the preceding character occurs at least n times. |
N |
Y |
N |
Y |
char{n,m} |
Matches strings in which the preceding character occurs at least n times but no more than m times. |
N |
Y |
N |
Y |
[string] |
Matches any character specified in the string enclosed in square brackets. |
N |
Y |
Y |
Y |
[^string] |
Matches any character not specified in the string enclosed in square brackets. |
N |
Y |
Y |
Y |
[char-char] |
Matches any character in the range, in ascending order of the character codes. |
N |
Y |
Y |
Y |
[^char-char] |
Matches any character not in the specified range, in ascending order of the character codes. |
N |
Y |
Y |
Y |
\special-char |
Handles the special character as an ordinary character. |
Y |
Y |
Y |
Y |