Regular Expression - * - matches zero or any number of the previous single expression

The asterisk (*) matches with any number of repetitions (including none) of the previous single expression. It is often preceded by dot (.*) meaning any number of any characters (including none) - the ultimate wildcard.
It only repeats one character or expression - 12*3 only 2 repeats 0+ times. 1 is unaffected.
Note that certain expressions e.g. 0* can result in matching nothing and can in some implementations cause inifinite loops, particularly when replacing.

Examples

Match line starting with 1 followed by any number of 2's followed by 3:

^12*3
This would match the following:
13
123
12223
12222223
It would not match the following:
113 - 1 cannot be repeated at beginning
1123 - 1 cannot be repeated at beginning
1243 - 4 cannot be appear before 3

Match the entire line with a b and c in it in that order, but with anything else in between:

.*a.*b.*c.*
This would match the following:
abc
123a456b789c0
Fabulous match!
acbcdc - the letters appear in the right order
It would not match the following:
cab - letters need to be in right order
aaabbbbb - all letters need to be there

Computing Articles