G.3 Comparison between types of regular expressions
The table below describes the differences in the types of regular expressions that can be used in Windows and other operating systems.
Expression |
Meaning |
Windows |
Solaris, AIX |
Linux |
|||
---|---|---|---|---|---|---|---|
JP1 |
Extd XPG4 |
Basic |
Extd |
Basic POSIX |
Extd POSIX |
||
String |
Matches lines containing the specified string. |
Y |
Y |
Y |
Y |
Y |
Y |
^string |
Matches the specified string at the beginning of a line. |
Y |
Y |
Y |
Y |
Y |
Y |
string$ |
Matches the specified string at the end of a line. |
Y |
Y |
Y |
Y |
Y |
Y |
^string$ |
Combination of ^ and $. Matches lines containing only the specified string. |
Y |
Y |
Y |
Y |
Y |
Y |
^$ |
Combination of ^ and $. Matches empty lines. |
Y |
Y |
Y |
Y |
Y |
Y |
. (period) |
Matches any single character. |
Y |
Y |
Y |
Y |
Y |
Y |
char* |
Matches strings of zero or more occurrences of the preceding character. |
Y |
Y |
Y |
Y |
Y |
Y |
.* |
Combination of a period (.) and asterisk (*). Matches any character string. |
Y |
Y |
Y |
Y |
Y |
Y |
char+ |
Matches strings of one or more occurrences of the preceding character. |
N |
Y |
N |
Y |
N |
Y |
char? |
Matches strings of zero or one occurrence of the preceding character. |
N |
Y |
N |
Y |
N |
Y |
regex|regex |
Matches either regular expression. |
N |
Y |
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 |
N |
Y |
char{n} |
Matches strings in which the preceding character occurs n times. |
N |
Y |
N |
Y |
N |
Y |
char{n,} |
Matches strings in which the preceding character occurs at least n times. |
N |
Y |
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 |
N |
Y |
[string] |
Matches any character specified in the string enclosed in square brackets. |
N |
Y |
N |
Y |
N |
Y |
[^string] |
Matches any character not specified in the string enclosed in square brackets. |
N |
Y |
N |
Y |
Y |
Y |
[char-char] |
Matches any character in the range, in ascending order of the character codes. |
N |
Y |
N |
Y |
Y |
Y |
[^char-char] |
Matches any character not in the specified range, in ascending order of the character codes. |
N |
Y |
N |
Y |
Y |
Y |
\special-char |
Handles the special character as an ordinary character. |
N |
Y |
N |
Y |
N |
Y |
- Legend:
-
JP1: JP1-specific regular expression
Extd XPG4: XPG4-compliant extended regular expression
Basic: XPG4 basic regular expression
Extd: XPG4 extended regular expression
Basic POSIX: POSIX 1003.2-compliant basic regular expression
Extd POSIX: POSIX 1003.2-compliant extended regular expression
Y: Can be used.
N: Cannot be used.