Thanks to visit codestin.com
Credit goes to programming.dev

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

  • tetris11@lemmy.ml
    Codestin Search App
    Codestin Search App
    Codestin Search App
    9
    ·
    7 months ago

    To put this into easier form:

    (nota digit) (1ormore digit) (literal dot) (1ormore digit)

    As far as I can see in that text, none of them end with "5.4” or "3.6” or "0.0”, so no your regex wont work

    Maybe change the middle " \d+" into “\d*” , or surround the “\d+\.” with a question mark group?

  • Diluvian@infosec.pub
    Codestin Search App
    Codestin Search App
    English
    Codestin Search App
    1
    ·
    4 months ago

    (?<!\d) -> Not sure why you’re doing this.

    \d+\. -> Look for at one or more digits followed by a period. None of the sentences have numbers before the period, and if the previous section didn’t exclude them, this would.

    \.\d+ -> look for a period followed immediately by one or more numbers. This should get most of the trailing 0’s, but you’ll miss the ones on their own newline and following a quotations mark.

    \.0\ -> If you only have a single character you’d like to remove, there’s no harm in enumerating it.