[英]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.