diff --git a/pae2xml.pl b/pae2xml.pl
index 0e8de94d06846c3e8098b9976c70b2aaf8d94495..929a5767a32abd1227fffe5d7e99bc85f343f01a 100755
--- a/pae2xml.pl
+++ b/pae2xml.pl
@@ -161,7 +161,7 @@ sub parse_pe {
   $pe =~ s/@�/@0�/gs; # make missing time signature explicit
   while ($pe =~ s/([^\-])(\d+)(\'|\,)(A|B|C|D|E|F|G)/$1$3$2$4/gs) {};  # octave first, then duration. Truly global.
 
-  if ($pe =~ /\s*(%([\w\-\+\d]+))?(@([\d\w\/]+))?\s*&?\s*(\$([^�]+))?�(.*)$/gs) {
+  if ($pe =~ /^\s*(%([\w\-\+\d]+))?(@([\d\w\/]+))?\s*&?\s*(\$([^�]*))?�(.*)$/gs) {
     my ($clef, $timesig, $keysig, $rest) = ($2, $4, $6, $7);
 
     print "Writing $filename...\n";