in reply to basic question: regular expression

The regex engine will not backtrack to find a "better" (i.e. longer) match; it will backtrack only as long as there no successful match. Greediness will apply only within the context of a given match.

In your two examples, the regex engine could find a successful match using the first "k" of your string. In such a case, it will simply report success and will not try anything to get a longer match by backtracking to the second "k".