\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.
13 Comments
tetris11@lemmy.ml · 9 pts · 1y
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?
a14o@feddit.org · 5 pts · 1y
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 pts · 1y
Whaaaaaaa, thank you!
sabreW4K3@lazysoci.al · 3 pts · 1y
Thank you. Every time someone shows me something regarding regex, I feel like I'm getting lessons from a deity.
You actually helped me out lots. I switched it to
(?<!\d)\.*\d{1}+thanks to your comment and it kinda did the job, so thank you.tetris11@lemmy.ml · 3 pts · 1y
oh nice solution, quite elegant
sabreW4K3@lazysoci.al · 2 pts · 1y
It's a terrible solution, but it works somewhat. Thanks for being nice.
bizdelnick@lemmy.ml · 5 pts · 1y
Not specifying the regex engine you use, first of all. Second, also describe what you mean by numbers that you want to match.
sabreW4K3@lazysoci.al · 1 pts · 1y
Sorry, I have no clue.
So you see in the screenshot, there's a random number at the end of some of the lines, I'm trying to match that.
bizdelnick@lemmy.ml · 2 pts · 1y
BTW if you don't need to capture the number,
\d$should match what you need. If regex syntax supports\d, of course.sabreW4K3@lazysoci.al · 1 pts · 1y
The number is the bit I want to capture.
bizdelnick@lemmy.ml · 2 pts · 1y
What do you use to apply your regex? Programming language, library, command line tool etc.
Is it decimal? One digit or multiple digits? Natural, rational?
sabreW4K3@lazysoci.al · 1 pts · 1y
Sorry it took so long to get back to you, I was trying to find a type of some sort.
The app offers this https://github.com/gedoor/legado/blob/master/app/src/main/assets/web/help/md/regexHelp.md Which I hope you find fruitful as an indication.
An ePub Reader called Legado
In the screenshot above, you can see it differs. I feel like I'm not doing your kindness justice with my sparse information, sorry! 🥺
Diluvian@infosec.pub · 1 pts · 346d
(?<!\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.