Does anyone know how can I replace the last N letters of words longer than X digits? I'm using this code
text = re.sub("[A-ZÀ-ÖØ-Ýà-öø-ÿa-z][A-ZÀ-ÖØ-Ýà-öø-ÿa-z]{7,}", "[\g<0>]", text)
This is an example output string of what I'm getting now.
253. Ficam [revogadas] a Lei nº 1.711, de 28 de outubro de 1952, e [respectiva] [legislação] [complementar], bem como as demais [disposições] em [contrário].
It puts a [] around words that are greater than 7 letters. However, I just need to wrap the last letter, not the whole word. Does anyone know how to achieve this? This is my expected output:
253. Ficam revogada[s] a Lei nº 1.711, de 28 de outubro de 1952, e respectiv[a] legislaçã[o] complement[r], bem como as demais disposiçõe[s] em contrári[o].