[Python] Python Regex - using re.sub to clean up a string

Discussão em 'Python' iniciado por Stack, Agosto 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am having some problems using regex sub to remove numbers from strings. Input strings can look like:

    "The Term' means 125 years commencing on and including 01 October 2015."

    "125 years commencing on 25th December 1996"

    "the term of 999 years from the 1st January 2011"


    What I want to do is remove the number and the word 'years' - I am also parsing the string for dates using DateFinder, but DateFinder interprets the number as a date - hence why I want to remove the number.

    Any thoughts on the regex expression to remove the number and the word 'years'?

    Continue reading...

Compartilhe esta Página