#Mathematica, 349 346 chars
h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...],
b = If[# > 0, ToString@#, "No"] <> " bottle" <>
If[# == 1, "", "s"] <> " of beer" &;
Print /@
StringCases[#, {"H" -> "Hello, world!", "Q" -> #,
"9" -> "" <>
Table[b@n <> " on the wall,\n" <> b@n <>
".\ntake one down, pass it around,\n" <> b[n - 1] <>
" on the wall." <> If[n == 1, "", "\n\n"], {n, 99,
1, -1}]}];, "Source code contains invalid characters"] &
alephalpha
- 50k
- 7
- 68
- 182