Regex pattern that does not match certain extensions?
问题 I have this pattern written ^.*\.(?!jpg$|png$).+$ However there is a problem - this pattern matches file.name.jpg (2 dots) It works correctly (does not match) on filename.jpg. I am trying to figure out how to make it not match ANY .jpg files even if the file's name has 2 or more dots in it. I tried using a look behind but python complains about not using a fixed width (which I'm not exactly sure what that means, but the file name will be variable length.) 回答1: This should work: ^.*\.(?!jpg$