in reply to Regex frustration

You need to escape the string sigil in line 2.
$str = "Logfile_Connection_Lost Hostname: \$1";