(?<!\d)\d+\.\d+ should match the numbers at the end of the lines and yet it won’t. What am I doing wrong?

  • a14o@feddit.org
    link
    fedilink
    arrow-up
    5
    ·
    2 个月前

    surround the “\d+.” with a question mark group?

    If you’re expecting decimals, that’s the preferred solution:

    (?<!\d)(\d+\.)?\d+(?=\s*$)

    Otherwise you could do simply

    (?<!\d)\d+(?=\s*$)

    I added the lookahead (?=\s*$) to match digits at the end of the line only with possible trailing spaces.