in reply to regexp not greedy

The ? in this context, .*?, will find every character up to the first occurrence of the next portion of the match. Leaving the ? out, .*, will suck up every character to the last occurrence of the next match.

This means your regex is finding the first * after a space, the *nadie, then looking from there until it finds *loc. This is why your regex is including that entire portion of the string.

To fix this for your scenario, the regex: \s\*([^\*]*)\*loc should work fine. This matches a space, followed by a *, then any number of characters that are NOT a *, followed by a *loc.

Buena Suerte!

Replies are listed 'Best First'.
Re^2: regexp not greedy
by ivosan (Initiate) on Dec 13, 2005 at 20:44 UTC
    Dear Monk, Thank you so much, it fixed.