Assume infile is a variable holding the name of an input file, and similarly outfile for output file. If infile ends in .js, I'd like to replace with .min.js and that's easy enough (I think).
outfile = re.sub(r'\b.js$', '.min.js', infile)
But my question is if infile ends in .min.js, then I do not want the substitution to take place. (Otherwise, I'll end up with .min.min.js) How can I accomplish this by using regular expression?
PS: This is not homework. If you're curious what this is for: this is for a small python script to do mass compress of JavaScript files in a directory.