You are here: PSPad forum > English discussion forum > Regex issue (percentages)

Regex issue (percentages)

Goto Page: 1 2 3 Next

#1 Regex issue (percentages)

Posted by: maki | Date: 06/24/2018 15:34 | IP: IP Logged

How to find percentages:
0 to 99.9%

Please corect regex
[0-99,9%]

Ignore the value 100%

Options: Reply | Quote | Up ^


#2 Re: Regex issue (percentages)

Posted by: pspad | Date: 06/24/2018 15:58 | IP: IP Logged

Do you really think you can enter interval 0%-99,9%? Regular expressions search for text expression, they doesn't evaluates mathematical expresions, functions e.t.c.

try something like this:
\d{1,2}(\.\d{1,2}%|%)

Options: Reply | Quote | Up ^


#3 Re: Regex issue (percentages)

Posted by: maki | Date: 06/24/2018 16:17 | IP: IP Logged

How to find all values from the range:
0% - 99.9%
Does not work properly:
\d{1,2}(\.\d{1,2}%|%)

Options: Reply | Quote | Up ^


#4 Re: Regex issue (percentages)

Posted by: maki | Date: 06/24/2018 16:40 | IP: IP Logged

in a text file

Options: Reply | Quote | Up ^


#5 Re: Regex issue (percentages)

Posted by: pspad | Date: 06/24/2018 17:12 | IP: IP Logged

maki:
How to find all values from the range:
0% - 99.9%
Does not work properly:
\d{1,2}(\.\d{1,2}%|%)

What does it mean "doesn't work properly"? Any example of your text what wasn't found? We don't see your file. If you want proper answer, you need give as enough information

Options: Reply | Quote | Up ^


#6 Re: Regex issue (percentages)

Posted by: maki | Date: 06/24/2018 18:55 | IP: IP Logged

R:\lkjghgK hJKhsym\-13974757_348284311.jpg -> I:\zekno-15076373\-13974757_348284311.mp3 - Kopiowanie zakończone powodzeniem 97%
Z:\BK ym\-15076373\-13974GGHJJD5348284311.jpg -> I:\Blask\-150373\13974757_348284311.mp3 - Kopiowanie zakończone powodzeniem 100%

Find every text in the lines in which all the values are from 0% to 99.9%, skip all of 100%

Options: Reply | Quote | Up ^


#7 Re: Regex issue (percentages)

Posted by: pspad | Date: 06/24/2018 19:23 | IP: IP Logged

If procent number is on new line, add ^ on the begin of reg.expression
^\d{1,2}(\.\d{1,2}%|%)

Options: Reply | Quote | Up ^


#8 Re: Regex issue (percentages)

Posted by: aGerman | Date: 06/24/2018 21:24 | IP: IP Logged

I think you were almost right, Jan. The only thing missing is that there must not be a digit or a point in front of your pattern.
[^\d\.]\d{1,2}(\.\d%|%)

Steffen

Options: Reply | Quote | Up ^


#9 Re: Regex issue (percentages)

Posted by: pspad | Date: 06/25/2018 04:12 | IP: IP Logged

If you exclude first char, you need to limit orrurence from zero or add case
(^|[^0-9])....
or
\d{0,}...
or it won't work on the begin of line

Options: Reply | Quote | Up ^


#10 Re: Regex issue (percentages)

Posted by: aGerman | Date: 06/25/2018 13:32 | IP: IP Logged

Absolutely right. But provided the example lines above are taken out of the real file then the percentage is rather on the end of the line winking smiley

Steffen

Edited 1 time(s). Last edit at 06/25/2018 13:33 by aGerman.

Options: Reply | Quote | Up ^


Goto Page: 1 2 3 Next





Editor PSPad - freeware editor, © 2001 - 2018 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR