in reply to regex to substitute 3 stars at beginnning of string with none?

'^([*]){3}' has the {3} on the outside of the (), so it is match ([*]} many times, each time saving a single *... you need to move them inside '^([*]{3})' then you will be happier.
                - Ant

Replies are listed 'Best First'.
Re: Re: regex to substitute 3 stars at beginnning of string with none?
by buckaduck (Chaplain) on Apr 24, 2001 at 00:55 UTC
    Update: A quick test confirms what merlyn says below. I have to admit that the correct behavior surprised me, but sounds sensible in retrospect. Here's my original post, anyway:

    To clarify: ([*]){3} is like ([*])([*])([*])

    That means that $1, $2, $3 each contain one of the asterisk characters. The suggested solution ([*]{3}) has all three characters inside the same set of parentheses, and therefore saves them all into $1.

    buckaduck