Special Characters
You can use special characters within a regular expression to cause the regular expression to match more than one string. A regular expression that includes a special character always matches the longest possible string, starting as far toward the beginning (left) of the line as possible.
Period
A period ( . ) matches any character (Table A-2).
Regular Expression | Matches | Examples |
---|---|---|
/.alk/ | All strings consisting of a SPACE followed by any character followed by alk | will talk, may balk |
/.ing/ | All strings consisting of any character preceding ing | sing song, ping, before inglenook |
Brackets
Brackets ( [ ] ) define a character class [1] that matches any single character within the brackets (Table A-3). If the first character following ...
Get A Practical Guide to Red Hat® Linux® 8 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.