in reply to parse a string

This might be slightly silly way to do it, and I'm not a regex expert. But I think this way your regex doesn't have to work through the whole string.
#!/usr/bin/perl $string = "something, something, something, this"; $string = reverse $string; $string =~ s/\S+\s//; $string = reverse $string; print $string;

UPDATE:japhy's answer is more efficient. I've updated my code it was originally $string =~ s/\S+\s(.*)/$1/;

Replies are listed 'Best First'.
Re: Re: parse a string
by japhy (Canon) on May 03, 2002 at 15:12 UTC
    That's almost how I would do it, since I reverse things like that all the time. Your substitution, though, does too much work. $string =~ s/\S+\s//; is good enough.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;