This is an example from the book Linux Command Line
If I am trying to match (555) 123-4567 or 555 123-4567 - the following extended regex can be used.
^\(?[0-9][0-9][0-9]\)? [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$
Simplified to
^\(?[0-9]{3}\)? [0-9]{3}-[0-9]{4}$
In the first example, does the second ? applies to the whole expression enclosed in the ()? Meaning it will match either 555 or (555).
In the second example:
echo "This works." | grep -E '[[:upper:]][[:upper:][:lower:] ]*\.'
Does * star apply to entire expression or only to the second part of expression that contains Upper and lower character classes?
If the previous expression was like this:
grep -E '[[:upper:][:upper:]][:lower:]*\.'
Would the * apply only to the lower character class?
[:lower:]is just a regular bracket expression (referring to the set of characters:,l,oetc. (GNU grep at least will guess that you meant[[:lower:]]and warn about that - but not actually treat it as such).