this post was submitted on 10 Jun 2025
10 points (100.0% liked)

RegEx

410 readers
1 users here now

Welcome to the RegEx community! This is a place where you can learn about and get help with regular expressions

A regular expression is a sequence of characters that specifies a match pattern in text. Theyre usually used for find, or find and replace operations on strings, or for input validation.


founded 2 years ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[–] a14o@feddit.org 5 points 6 months ago (1 children)

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.

[–] sabreW4K3@lazysoci.al 1 points 6 months ago

Whaaaaaaa, thank you!