Metacharacters allow you to specify repeated occurrences of the character. Consider the following expression:
11*0
It will match each of the following lines:
10
110
111110
1111111111111111111111111110
These meta-characters make the regular expression scalable.
Now let's look at a couple of metacharacters that specify the span and determine the length of the span. You can specify the minimum or maximum number of occurrences of a letter or regular expression.
Use \{and \} in grep and sed. AWK does not support. In any case, curly braces surround one or two parameters.
\{n,m\}
N and m are integers between 0 and 255. If you specify only \{n\} itself, it will exactly match the preceding character or n occurrences of the regular expression. If \{n,m\} is specified, then the number of occurrences is any number between N and M.
For example, the following expression matches "1001", "10001" and "100001", but does not match "101" or "1000001":
10\{2,4\}1
This pair of metacharacters is useful for matching data in fixed-length fields, which can be obtained from the database and used to match formatted data such as phone numbers, U.S. Social Security numbers, inventory part IDs, and so on. For example, the social Security number is formatted as: 3 digits, a hyphen, followed by 2 digits, a hyphen, and then 4 digits. Can be described as a pattern:
[0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\}
Similarly, the North American phone number can be described using the following regular expression:
[0-9]\{3\}-[0-9]\{4\}
If you use awk, the curly braces are not available, and you can simply repeat the appropriate number of character classes:
[0-9] [0-9] [0-9]-[0-9][0-9][0-9][0-9]
Reference: http://www.linuxawk.com/communication/451.html
Linux Regular Expressions-the span of characters