Everything:速度最快的文件搜索工具之正则表达式
最先是从善用佳软上知道此软件的,原文是:Everything:速度最快的文件搜索工具(中文语言包发布)。推荐您先读完善用佳软的介绍,再来读本贴的内容。
出发点不同,我关注的是它是否支持正则表达式。在本软件的faq页上一搜索regex,就看到标题:How do I use regex,真是很欣慰。简单翻译一下与正则式相关的部分。
先看一下通配符。在漆黑的DOS中摸爬滚打过的老同志可以略过。
引用:2.3 How do I use wildcards?
2.3 如何使用通配符?
Using a * in your search will match any number of any type of character.
For example, here's how to search for files and folders that start with e and end with g: e*g
在搜索时使用*可以匹配任何数量的任何字符。
例如,使用e*g可以搜索到任何以e开头,以g结尾的文件和文件夹。
Using a ? in your search will match one character.
For example, here's how to search for files that have a 2 letter file extension: *.??
使用半角?号可以匹配任意单个字符。
例如,可以使用*.??来搜索后缀名为2个字符的文件。注意到,通配符*.??与正则式的原理是不一样的。通配符??精确地匹配2位字符,但是如果是正则式的话,还需要有一个结尾的$来保证这一点,呵呵。
再来看一下正则式部分。在xbeta.info上,正则式只是附带提了一下:支持正则表达式。现在,我们看一下它支持哪些元字符,支持哪种风格的正则式。抄书:
引用:2.4 How do I use regex?
| A vertical bar separates alternatives. For example, gray|grey can match "gray" or "grey".
竖线用来分隔备选项。例如,gray|grey 可以匹配"gray" 或 "grey"
() Parentheses are used to define the scope and precedence of the operators (among other uses). For example, gray|grey and gr(a|e)y are equivalent patterns which both describe the set of "gray" and "grey".
括号用来界定范围和操作符的优先权。例如,gray|grey 与 gr(a|e)y 两种模式的效果是相同的,都是用来描述"gray"与"grey"两种匹配项。
? The question mark indicates there is zero or one of the preceding element. For example, colou?r matches both "color" and "colour".
问号表示之前的元素可以出现0次或1次。例如,colou?r 匹配 "color" 和 "colour".
* The asterisk indicates there are zero or more of the preceding element. For example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on.
星号表示之前的元素可以出现0次或任意多次。例如,ab*c 匹配 "ac", "abc", "abbc", "abbbc", 诸如此类。
+ The plus sign indicates that there is one or more of the preceding element. For example, ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac".
加号表示之前的元素可以出现1次或更多次。例如,ab+c 匹配 "abc", "abbc", "abbc", "abbbc", 诸如此类,但是不匹配"ac"。
. Matches any single character except newlines (exactly which characters are considered newlines is flavor, character encoding, and platform specific, but it is safe to assume that the line feed character is included). Within POSIX bracket expressions, the dot character matches a literal dot. For example, a.c matches "abc", etc., but [a.c] matches only "a", ".", or "c".
点号匹配除新行符之外的任何一位字符(精确地说,至于哪种字符是换行符,这要取决于正则式风格,字符编码系统,以及所使用的操作系统,但是,将换行符包括进来是无伤大雅的)。在POSIX风格的方括号表达式中,点号匹配普通文本‘.’,例如,a.c匹配"abc"等文本,但是,[a.c]只匹配'a','.',或'c'。
[ ] A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches "a", "b", or "c". [a-z] specifies a range which matches any lowercase letter from "a" to "z". These forms can be mixed: [abcx-z] matches "a", "b", "c", "x", "y", and "z", as does [a-cx-z]
方括号表达式匹配在其内部的任意一位字符。例如,[abc]匹配"a","b"或"c"。[a-z]匹配从a至z的区间内任意一位小写字母。这两种方式可以混合使用,例如,[abcx-z] 匹配 "a", "b", "c", "x", "y", 和 "z";与 [a-cx-z]的作用一样。
[^ ] Matches a single character that is not contained within the brackets. For example, [^abc] matches any character other than "a", "b", or "c". [^a-z] matches any single character that is not a lowercase letter from "a" to "z". As above, literal characters and ranges can be mixed.
匹配任何不在方括号内的字符。例如,[^abc]匹配除"a", "b", "c"之外的任何一位字符。[^a-z] 匹配任何不在小写字母a至z区间内的字符。与上一条类似,普通文本可以和区间符-混合使用。
^ Matches the starting position within the string. In line-based tools, it matches the starting position of any line.
^匹配文本行开头的位置。注意,是位置,而不是具体字符。在以“行”为单位处理文本的工具中,它匹配任何一行的开始位置。
$ Matches the ending position of the string or the position just before a string-ending newline. In line-based tools, it matches the ending position of any line.
作用与^相反,它匹配文本行的结尾,下一行文本之前的位置。在以“行”为单位处理文本的工具中,它匹配任何一行的结尾位置。
{m,n} Matches the preceding element at least m and not more than n times. For example, a{3,5} matches only "aaa", "aaaa", and "aaaaa". This is not found in a few, older instances of regular expressions.
与*,+一样,{m,n}属于量词,用来限定匹配的次数。{m,n}匹配之前元素至少m次,至多n次。例如,a{3,5}只匹配"aaa", "aaaa", 和 "aaaaa"。本特性在少数旧式正则表达式中不被支持。
好累呀,终于翻译完了。
可以看到,everything支持的仅仅是正则式中最基本的特性。但是这也已经足够强大了。
支持正则表达式,快速,是我喜欢everything的最主要原因。用它来搜索文件名足够了。搜索文件内容的话,我们有PowerGREP。
我不喜欢everything的原因是,不支持fat分区格式。可以想见,在linux下,用wine启动everything,它也必定不支持ext[23]之类的分区格式。不过,在linux下,我们有ls -R * | grep 'pattern',呵呵。
最先是从善用佳软上知道此软件的,原文是:Everything:速度最快的文件搜索工具(中文语言包发布)。推荐您先读完善用佳软的介绍,再来读本贴的内容。
出发点不同,我关注的是它是否支持正则表达式。在本软件的faq页上一搜索regex,就看到标题:How do I use regex,真是很欣慰。简单翻译一下与正则式相关的部分。
先看一下通配符。在漆黑的DOS中摸爬滚打过的老同志可以略过。
引用:2.3 How do I use wildcards?
2.3 如何使用通配符?
Using a * in your search will match any number of any type of character.
For example, here's how to search for files and folders that start with e and end with g: e*g
在搜索时使用*可以匹配任何数量的任何字符。
例如,使用e*g可以搜索到任何以e开头,以g结尾的文件和文件夹。
Using a ? in your search will match one character.
For example, here's how to search for files that have a 2 letter file extension: *.??
使用半角?号可以匹配任意单个字符。
例如,可以使用*.??来搜索后缀名为2个字符的文件。注意到,通配符*.??与正则式的原理是不一样的。通配符??精确地匹配2位字符,但是如果是正则式的话,还需要有一个结尾的$来保证这一点,呵呵。
再来看一下正则式部分。在xbeta.info上,正则式只是附带提了一下:支持正则表达式。现在,我们看一下它支持哪些元字符,支持哪种风格的正则式。抄书:
引用:2.4 How do I use regex?
| A vertical bar separates alternatives. For example, gray|grey can match "gray" or "grey".
竖线用来分隔备选项。例如,gray|grey 可以匹配"gray" 或 "grey"
() Parentheses are used to define the scope and precedence of the operators (among other uses). For example, gray|grey and gr(a|e)y are equivalent patterns which both describe the set of "gray" and "grey".
括号用来界定范围和操作符的优先权。例如,gray|grey 与 gr(a|e)y 两种模式的效果是相同的,都是用来描述"gray"与"grey"两种匹配项。
? The question mark indicates there is zero or one of the preceding element. For example, colou?r matches both "color" and "colour".
问号表示之前的元素可以出现0次或1次。例如,colou?r 匹配 "color" 和 "colour".
* The asterisk indicates there are zero or more of the preceding element. For example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on.
星号表示之前的元素可以出现0次或任意多次。例如,ab*c 匹配 "ac", "abc", "abbc", "abbbc", 诸如此类。
+ The plus sign indicates that there is one or more of the preceding element. For example, ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac".
加号表示之前的元素可以出现1次或更多次。例如,ab+c 匹配 "abc", "abbc", "abbc", "abbbc", 诸如此类,但是不匹配"ac"。
. Matches any single character except newlines (exactly which characters are considered newlines is flavor, character encoding, and platform specific, but it is safe to assume that the line feed character is included). Within POSIX bracket expressions, the dot character matches a literal dot. For example, a.c matches "abc", etc., but [a.c] matches only "a", ".", or "c".
点号匹配除新行符之外的任何一位字符(精确地说,至于哪种字符是换行符,这要取决于正则式风格,字符编码系统,以及所使用的操作系统,但是,将换行符包括进来是无伤大雅的)。在POSIX风格的方括号表达式中,点号匹配普通文本‘.’,例如,a.c匹配"abc"等文本,但是,[a.c]只匹配'a','.',或'c'。
[ ] A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches "a", "b", or "c". [a-z] specifies a range which matches any lowercase letter from "a" to "z". These forms can be mixed: [abcx-z] matches "a", "b", "c", "x", "y", and "z", as does [a-cx-z]
方括号表达式匹配在其内部的任意一位字符。例如,[abc]匹配"a","b"或"c"。[a-z]匹配从a至z的区间内任意一位小写字母。这两种方式可以混合使用,例如,[abcx-z] 匹配 "a", "b", "c", "x", "y", 和 "z";与 [a-cx-z]的作用一样。
[^ ] Matches a single character that is not contained within the brackets. For example, [^abc] matches any character other than "a", "b", or "c". [^a-z] matches any single character that is not a lowercase letter from "a" to "z". As above, literal characters and ranges can be mixed.
匹配任何不在方括号内的字符。例如,[^abc]匹配除"a", "b", "c"之外的任何一位字符。[^a-z] 匹配任何不在小写字母a至z区间内的字符。与上一条类似,普通文本可以和区间符-混合使用。
^ Matches the starting position within the string. In line-based tools, it matches the starting position of any line.
^匹配文本行开头的位置。注意,是位置,而不是具体字符。在以“行”为单位处理文本的工具中,它匹配任何一行的开始位置。
$ Matches the ending position of the string or the position just before a string-ending newline. In line-based tools, it matches the ending position of any line.
作用与^相反,它匹配文本行的结尾,下一行文本之前的位置。在以“行”为单位处理文本的工具中,它匹配任何一行的结尾位置。
{m,n} Matches the preceding element at least m and not more than n times. For example, a{3,5} matches only "aaa", "aaaa", and "aaaaa". This is not found in a few, older instances of regular expressions.
与*,+一样,{m,n}属于量词,用来限定匹配的次数。{m,n}匹配之前元素至少m次,至多n次。例如,a{3,5}只匹配"aaa", "aaaa", 和 "aaaaa"。本特性在少数旧式正则表达式中不被支持。
好累呀,终于翻译完了。
可以看到,everything支持的仅仅是正则式中最基本的特性。但是这也已经足够强大了。
支持正则表达式,快速,是我喜欢everything的最主要原因。用它来搜索文件名足够了。搜索文件内容的话,我们有PowerGREP。
我不喜欢everything的原因是,不支持fat分区格式。可以想见,在linux下,用wine启动everything,它也必定不支持ext[23]之类的分区格式。不过,在linux下,我们有ls -R * | grep 'pattern',呵呵。
作者:admin@常来吧
地址:http://www.chl8.com/post/831/
版权所有!转载时请必须遵守以链接形式署名-非商业性使用-完整方式共享!
欢迎在常来吧留言&评论!
上一篇:
Everything:速度最快
Everything:速度最快

文章来自: 本站原创
Tags:
文件搜索我只用Everyth