title: Regular expression: replace the suffix of a string ending in '.js' but not 'min.js'
body: <p>Assume infile is a variable holding the name of an input file, and similarly outfile for output file.  If infile ends in <strong>.js</strong>, I'd like to replace with <strong>.min.js</strong> and that's easy enough (I think).</p>
  
  <p><strong>outfile = re.sub(r'\b.js$', '.min.js', infile)</strong></p>
  
  <p>But my question is if infile ends in <strong>.min.js</strong>, then I do not want the substitution to take place.  (Otherwise, I'll end up with <strong>.min.min.js</strong>)  How can I accomplish this by using regular expression?</p>
  
  <p>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.</p>