quantifiers
grep -oE '<[^>]+>' page.html
Greedy
* and + are greedy by default
They match as much as possible
On <a><b> a greedy <.*> eats both tags in one match
Non greedy
*? and +? are lazy
They match as little as possible
Use lazy quantifiers for delimiters
Possessive
*+ and ++ do not backtrack
That can make a pattern faster
It can also make it fail where a backtracking engine would succeed
Anchoring
A quantifier without an anchor matches anywhere in the line That is usually not what you want Anchor the pattern before adding quantifiers
Next
Anchors in 04 anchors
Posted