简体   繁体   English

如何使用正则表达式查找大于100%的值?

[英]how can I find values greater than 100% using regular expression?

I'm dealing with a huge amount of CSS across several files and trying to debug issues with layout looking for bugs like width:105% 我正在处理几个文件中的大量CSS并尝试调试布局问题,寻找width:105%错误width:105%

I only have access to notepad++ on a Windows machine that supports Regular Expression in Search . 我只能在支持搜索中的正则表达式的Windows机器上访问notepad ++

([1-9]0[1-9]|[1-9]{2}\d|[2-9]\d{2}|\d{4,})\s*%

Should do the trick for all numbers in the range of 101 and upward. 应该为101和向上范围内的所有数字做诀窍。

101%
110%
210%
999 %
1000000000%

Will all match. 将全部匹配。

Assuming they are all non-negative integer percentages and not zero-prefixed, you could negate anything with 0% to 100% - but only run that over lines with a % in them. 假设它们都是非负整数百分比而不是零前缀,你可以否定0% to 100%任何东西 - 但只能在含有%的行上运行。

eg on the command line 例如在命令行上

fgrep % something.css | egrep -v ":\s*[0-9]{1,2}%" | fgrep -v 100%

The regular expression will match 0-99%, so I just remove 100% on it's own. 正则表达式将匹配0-99%,所以我只删除它自己的100%。

1(?:0[1-9]|[1-9]\d)%

Would be my guess. 我的猜测。 That matches 10* (where * > 0 ) or 1** where * > 10 匹配10* (其中* > 0 )或1** ,其中* > 10

EDIT 编辑

For a better method to handle > 100 numbers (and not limit at 999): 为了更好的方法来处理> 100个数字(并且不限制在999):

(?:\d{4,}|[1-9]0[1-9]|[1-9][1-9]\d|[2-9]\d{2})
[1-9]0*\d{2,}%

应该适用于任何数字> = 100。

I suppose regex for finding values bigger than 100% percent would be : 我认为正则表达式找到大于100%的值将是:

width\s?:\s?[0-9]*[1-9]{1}[0-9]{1}[0-9]{1}%

This should find everything even 190999% 这应该找到一切甚至190999%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查元素宽度是否大于100% - How to check if element width is greater than 100% 如何使用正则表达式读取文本文件中的类,ID或标签样式? - How can I read classes, IDs or tags styles inside a text file using regular expression? 如何将 iframe 与大于 100% 的最大宽度居中对齐,以便裁剪部分 iframe 宽度? - How do I center align iframe with a max-width greater than 100% in order to crop some of the iframe width? 如何使宽度超过 100% 的表格居中? - How can I center a table with width more than 100%? 如果选择器 :out-of-range 小于或大于输入范围,我如何检查 css? - how can I check with css if the selector :out-of-range is less than or greater than the input range? 无法使用正则表达式在字符串中找到模式 - Unable to find a pattern in a string using regular expression 如何找到与正则表达式不匹配的所有内容 - How to find everything that is not matching a regular expression 反应:如果其他逻辑大于100 - REACT: If Else logic, greater than 100 在CSS文件中查找重复的十六进制值的正则表达式 - Regular expression to find repeating hex values in css files 大于零的数据如何更改字体颜色? - How can I change the font-color of a data when it is greater than zero?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM