Perl style regex for the first example