Improved matching of special characters