According to the SAM format white paper (http://samtools.sourceforge.net/SAM1.pdf) header lines should be matched by /^@[A-Za-z][A-Za-z](\t[A-Za-z][A-Za-z0-9]:[ -~])+$/ or /^@CO\t.*/. However, this does not seem to be the case with the example in the format white paper - or with real world data.
@masha it does look odd, but it's the same format as [A-Z] it means match any characters between (including endpoints) " " and "~". ord(" ") == 32 and ord("~") == 126
Hey, that is pretty cool!