Wildcard regular expressions are useful for selecting files, but they cannot search the text within files. For that, you need to use the editor regular expressions. These are as follows:
This is equivalent to the wildcard ``?''. For example, .iddle will match ``diddle'', ``middle'', or any other word beginning with some letter followed by the string ``iddle''.
As a single character is taken to be a literal regular expression matching only itself, this means that a character followed by an asterisk matches zero or more instances of itself. Consequently, ``.'' matches zero or more repeating instances of any character, and ``a'' matches zero or more ``a''s in a row.
Note that this behavior is not the same as that of the asterisk wildcard character. The shell interprets the asterisk wildcard to mean ``zero or more characters''; in an editor regular expression, the asterisk matches zero or more instances of the preceding regular expression.
Note that, like the asterisk, this editor regular expression metacharacter does not have the same effect as its wildcard counterpart, which matches a single character, not an instance of a preceding regular expression.
There is a subtle difference between the interpretation of regular
expressions containing a ``'' and a ``+''. For example,
suppose we have the word list:
The expression ``fr+'' will match only ``fred'' and ``frog'', because it is constrained to match an ``f'' followed by at least one ``r''. However, ``fr'' will match all of these words, because it matches an ``f'' followed by zero or more instances of the letter ``r''.
If you are not certain of the spelling of a word that you are
searching for, this construction comes in handy. For example,
matches any of:
In the next specification, the ^ is a literal:
The ^ character is octal ASCII 136
In the following, the dollar is used to match a string occurring at
the end of a line:
It's the end of the line, folks$
In the next example, $ is a literal:
He stole $50000