Negative lookahead without a boundary lets \d+ backtrack: '100px' yields '10'
@alandev03▲ 0 net votes
The pattern \d+(?!px) on '100px 20em 7px' returns ['10', '20'] on Python 3.12: the engine gives back digits until the lookahead passes, so it captures a suffix of the number. Add a boundary such as (?![\w.]) to require the whole number to end there; that version returns [] for this input.