英文:
filter regex to percentage
问题
在Case 1中,您可以使用以下正则表达式来过滤超过8%的百分比,示例:Increased % 8.05
:
Increased % (?:[89]\.\d+|\d{2,}\.\d+)
在Case 2中,您可以使用以下正则表达式来过滤超过10%的百分比,示例:Increased % 12.05
:
Increased % (?:10\.\d+|1[1-9]\.\d+)
英文:
I would like two examples of regular expression to filter percentage:
I have the following cases:
Case 1:
Increased % 3.05
Increased % 8.05
Increased % 12.05
Case 2:
Increased % 3.05
Increased % 8.05
Increased % 12.05
In case 1, I would like a regular expression to filter any percentage above 8%
, example: Increased % 8.05
In case 2, I would like a regular expression to filter any percentage above 10%
, example: Increased % 12.05
Any idea how to assemble a regex string for case 1 and case 2?
I don't have much knowledge in regex and all the alternatives I tested didn't come close to the expected result.
答案1
得分: 0
要过滤超过10%的内容:
^.*%\s*[1-9]\d+(?:\.\d+)?
[1-9]\d+(?:\.\d+)?
-> 匹配1
到9
和一个或多个数字 + 可选的小数部分
要过滤超过8%的内容:
^.*%\s*(?:8|\d\d+)(?:\.\d+)?
(?:8|\d\d+)(?:\.\d+)?
-> 匹配8
或两个或更多数字 + 可选的小数部分
英文:
To filter above 10%:
^.*%\s*[1-9]\d+(?:\.\d+)?
[1-9]\d+(?:\.\d+)?
-> matches 1
to 9
and one or more digits + optional decimal part
To filter above 8%:
^.*%\s*(?:8|\d\d+)(?:\.\d+)?
(?:8|\d\d+)(?:\.\d+)?
-> matches 8
or two or more digits + optional decimal part
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论