Iczer Posted June 18, 2016 Share Posted June 18, 2016 How it should be done? Autoit regexp: $sHeader = "attachment; filename*=UTF-8''cURL.au3" $sFilename = StringRegExpReplace($sHeader, "(?i)(\A.*?filename)(\*?\=.*?)([^']+)$","$3") JavaScript: $sJavascript &= 'var responseHeaders = request.getResponseHeader("Content-Disposition");' $sJavascript &= 'var expr = new RegExp(".*=.+?"(.+)");' $sJavascript &= 'var fileName = responseHeaders.replace(expr,"$3");' it working well in most cases, but if filename encoded as defined by RFC 2231, JavaScript version give wrong result and this $sJavascript &= 'var expr = new RegExp("(\\A.*?filename)(\\*?\\=.*?)([^\\x27\\x60]+)$");' $sJavascript &= 'var fileName = responseHeaders.replace(expr,"$3");' also fail. How i can correctly reproduce auto-it regexp in JavaScript? Link to comment Share on other sites More sharing options...
Bowmore Posted June 18, 2016 Share Posted June 18, 2016 Could you please specify which browsers you use as the implementations have slight differences joco1 1 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Iczer Posted June 18, 2016 Author Share Posted June 18, 2016 its FireFox Link to comment Share on other sites More sharing options...
Bowmore Posted June 18, 2016 Share Posted June 18, 2016 Try this var expr = /(^.*?filename)(\*?\=.*?)([^']+)$/mg; fileName = responseHeaders.replace(expr, "$3"); joco1 1 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Iczer Posted June 18, 2016 Author Share Posted June 18, 2016 thanks! its working Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now