in reply to basic question: regular expression


The reason is that * and ? also match zero times. So in your example 1, the regEx already matches the first k, which is followed by zero as. Even if a longer sequence comes later on in the string.

If there is a match, the regEx tries to be as greedy as possible, that's why you get kkka in example 2.

HTH, Rata