in reply to Re: Regexpresions
in thread Regexpresions

You probably were aware of this and just mistyped, but...

The ? when used as it is in .? means zero or one, as stated by another poster above. .? does not mean one or more, that would be .+.

A quick list:

? -- optional, zero or one + -- required and repeatable, one or more * -- optional and repeatable, zero or more
All of these can be modified by placing a '?' after them, .+? in this usage however the '?' is affecting the greediness of the operator. Without the '?' it will attempt to match as many as possible (greedy), with the '?' it will attempt to match as few as required (non-greedy).

There is a great book, Mastering Regular Expressions on this topic that is a very worthwhile read.

Replies are listed 'Best First'.
Re: Re: Re: Regexpresions
by ozone (Friar) on Aug 22, 2001 at 14:13 UTC
    D'Oh! Must be all these late nights... :-)
Re: Re: Re: Regexpresions
by Anonymous Monk on Aug 21, 2001 at 18:14 UTC

    Ah, thanks. The book i had suggested that .? would work in the way .+? does. Plus in the second regexpresion I ment to type:

    /\\([^\\]+)/

    The thing I was puzzeled about is perhaps better explained with the fact that this doesn't seem to work:

    /\\([^\\]+)\\/

    Maybe it was just that it was 4 in the morning at the time.