negative lookahead assertion not working in python
问题 Task: - given: a list of images filenames - todo: create a new list with filenames not containing the word "thumb" - i.e. only target the non-thumbnail images (with PIL - Python Imaging Library). I've tried r".*(?!thumb).*" but it failed. I've found the solution (here on stackoverflow) to prepend a ^ to the regex and to put the .* into the negative lookahead: r"^(?!.*thumb).*" and this now works. The thing is, I would like to understand why my first solution did not work but I don't. Since