Fixing issue with deprecated way of looking up variables

Also, added proper escaping to the regex.