I'm not talking about -o option. Posix says:
The search for a matching sequence starts at the beginning of a string and stops when the first sequence matching the expression is found, where "first" is defined to mean "begins earliest in the string". If the pattern permits a variable number of matching characters and thus there is more than one such sequence starting at that point, the longest such sequence is matched. For example, the BRE "bb*" matches the second to fourth characters of the string "abbbc", and the ERE "(wee|week)(knights|night)" matches all ten characters of the string "weeknights".
And I want to verify what is being said in posix and this tutorial regTutorialSite:
A POSIX-compliant engine will still find the leftmost match. If you apply Set|SetValue to Set or SetValue once, it will match Set.
How to "apply once"? When i run grep -o the result is two strings: Set and SetValue, but not just " one leftmost " . That is, I read about one thing, but in practice I get something else. So, how to see what string was matched by regex?
(Perhaps the question was formulated incorrectly or could have been better)
grep -o
, I think it's defined to print all matches, so again, there's no conflict between what you saw and what is documented. Grep isn't the same thing as the regex engine in the C library, and it's not reasonable to expect a description of the library functions would describe accurately the behavior of grep.