public static function parse($str, $currency = 'USD')
    {
        // get currency object
        $currency = (is_string($currency) ? new Currency($currency) : $currency);

        // remove HTML encoded characters: http://stackoverflow.com/a/657670
        // special characters that arrive like &0234;
        $str = preg_replace("/&#?[a-z0-9]{2,8};/i", '', $str);

        // remove all leading non numbers
        $str = preg_replace('/^[^0-9]*/', '', $str);

        // remove all thousands separators
        if (strlen($currency->getThousandSeparator())) {
            $str = str_replace($currency->getThousandSeparator(), '', $str);
        }

        if (strlen($currency->getDecimalSeparator())) {
        // make decimal separator regex safe
            $char = preg_quote($currency->getDecimalSeparator());
            // remove all other characters
            $str = preg_replace('/[^'.$char.'\d]/', "", $str);
            // convert all decimal seperators to PHP/bcmath safe decimal '.'
            $str = preg_replace('/'.$char.'/', ".", $str);
        } else {
            // for currencies that do not have decimal points
            // remove all other characters
            $str = preg_replace('/[^\d]/', "", $str);
        }

        return new Money($str, $currency);
    }