The asterisk character is used to match a sequence of zero or more characters in a character sequence. Returning to our constants example:
#define threshold_low 2400
#define threshold_high 4800
#define threshold_mid 3600
In our previous case we used the + character to match a sequence of one or more characters. Our search string was:
threshold_[A-Za-z]+
Alternatively, we could have used the asterisk character * to match our character sequence zero or more times. Our new expression becomes:
threshold_[A-Za-z]*
This will now match the following strings:
#define threshold_low 2400
#define threshold_high 4800
#define threshold_mid 3600
It will stop at the first character that is not in the given set. However, if we had an expression:
#define threshold_
it would match this expression as well and we would get the following:
#define threshold_low 2400
#define threshold_high 4800
#define threshold_mid 3600
#define threshold_
This is because the * character matches 0 or more occurrences of the character specified in our group. In the last example, threshold_ has 0 or more characters in our set [A-Za-z] so it matches as well.
In the next example we'll look at matching a sequence of characters starting at the beginning of the line.