in reply to regex problem

It matches for me, but not as you want it to. Your regex is too relaxed. The (.*?) tries to match zero characters first (and succeeds). The \s*? tries to match zero whitespace (and succeeds). The (.*?$) tries matching zero characters (and fails), and eventually ends up matching the whole line. Boo.

You want something like /(.*?)\s+(.*)/, or perhaps /(\S+)\s+(.*)/. Better yet, use split(). my ($ng, $desc) = split ' ', $record, 2;

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: regex problem
by Anonymous Monk on Jan 10, 2002 at 00:44 UTC
    my ($ng, $desc) = split ' ', $record, 2;

    did the trick with:

     $desc = "no description available" unless ($desc);

    Thanks for your help!!