in reply to Re: Regexp explanation
in thread Regexp explanation

I want my string to accept composed word which have a character "-" between them such as "tear-down" or by-the-house; I don't need to be surrounded by quotes... maybe to get everything separate by blanks in a sentence?

Replies are listed 'Best First'.
Re: Re: Re: Regexp explanation
by matija (Priest) on Apr 02, 2004 at 21:02 UTC
    So then why did you put the quotes in your regex?

    Never mind. It is important to remember that the Perl regexps are greedy: they will match as much as possible. Therefore to match a word, you only need to specify what a word is, there is no need to define what it's delimiters might be.

    That simplifies the regexp to:

    /([\w-]+)/g