79413881

Date: 2025-02-05 07:00:58
Score: 1
Natty:
Report link

This will replace 'ABC' with 'bueno'only if it is not followed by '.png' or ' thumb.png'.

import re

texto = "ABC ABC. ABC.png ABC thumb\.png"

regex = r"\bABC\b(?!\.png|\s?thumb.png)"

novo = re.sub(regex, "bueno", texto)

print(novo)

RESULT:

bueno bueno. ABC.png ABC thumb.png
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: rich neadle