my $line = q{one }; $line =~ / ([^<]+) (?: < (two|three) > )? /x; print $1, $2;