<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>我爱正则表达式 &#187; 软件</title>
	<atom:link href="http://iregex.org/blog/category/software/feed" rel="self" type="application/rss+xml" />
	<link>http://iregex.org</link>
	<description>原创、翻译、转载关于正则表达式的文章</description>
	<lastBuildDate>Sun, 27 Jun 2010 04:20:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><atom:link rel="hub" href="http://www.feedsky.com/api/RPC2"/><atom:link rel="hub" href="http://blogsearch.google.com/ping/RPC2"/><atom:link rel="hub" href="http://blog.yodao.com/ping/RPC2"/><atom:link rel="hub" href="http://www.feedsky.com/api/RPC2"/><atom:link rel="hub" href="http://www.xianguo.com/xmlrpc/ping.php"/><atom:link rel="hub" href="http://www.zhuaxia.com/rpc/server.php"/><atom:link rel="hub" href="http://rpc.technorati.com/rpc/ping"/><atom:link rel="hub" href="http://rpc.pingomatic.com/"/>	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://iregex.org/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>EmEditor中的正则表达式</title>
		<link>http://iregex.org/blog/regular-expressions-in-emeditor.html</link>
		<comments>http://iregex.org/blog/regular-expressions-in-emeditor.html#comments</comments>
		<pubDate>Sat, 25 Apr 2009 13:32:52 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[emeditor]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=59</guid>
		<description><![CDATA[Rex按：原本在翻译EmEditor自带的帮助文件中关于正则表达式的部分，翻译至一半，忽然想搜索一下是否有人已经翻译。结果发现，果然已经有人早已做好。我就不再重复劳动了。 文章来源：【... ]]></description>
			<content:encoded><![CDATA[<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;"><p>Rex按：原本在翻译EmEditor自带的帮助文件中关于正则表达式的部分，翻译至一半，忽然想搜索一下是否有人已经翻译。结果发现，果然已经有人早已做好。我就不再重复劳动了。
</p></blockquote>
<p>文章来源：<a target="_blank" href="http://bbs.et8.net/bbs/showthread.php?t=652159"><strong>【正则表达式专题】正则表达式介绍及其在EmEditor的应用(更新)</strong></a><br />
作者：<a class="bigusername" href="http://bbs.et8.net/bbs/member.php?s=ecd1284aece1a82997da2c6c521ffc2d&amp;u=27811">nb590</a></p>
<p>应lyh728之约, 也算是对命令行和正则表达式专题的支持, 随便写点东西介绍下正则表达式的基础概念. 由于本版偏重应用, 故只取EmEditor的正则子集来作介绍. Perl 和 CLR 的 Regex 的内容远比这类编辑器所支持的功能多. </p>
<p>正则表达式实在包含的内容太多, 仅仅用一篇文章来涵盖是没可能的了, 所以我只是简要的做些介绍和基本的模式应用举例. 即使这样也需要多次分章节的来连载了~~~  闲话少说, 以下正文:</p>
<p>正则表达式, 英文 Regular expression, 简写Regexes或Regex. </p>
<p><b>应用概述</b>: 提供与预期的搜索结果匹配的确切文本来进行字符串的搜索和替换操作, 这种技术不仅仅用于开发领域, 更被集成到一些常见的文本扩展编辑器, 如UltraEdit, Emeditor等. 历史上第一个实用应用程序是Unix 中的qed 编辑器。</p>
<p>举一个简单的类比: 我们对DOS中的通配符&#8221;*&#8221;和&#8221;?&#8221;应该很熟悉, 如命令&#8221;dir *.exe&#8221; 将列出所有后缀名为exe的文件名. 正则表达式提供的方法与其类似, 而且远比通配符强大的多.</p>
<p>从某种意义上说, 正则表达式是一种语言, 通过及其简短的一行代码即可以高效, 精确的描述要匹配的复杂文本, 当然, 它最大的优点也是他最大的缺点: 语法复杂, 创建困难. (熟悉之后就可以忽略后半句了 <img src="images/smilies/Default/dft011.gif" alt="" title="Stick Out Tongue" class="inlineimg" border="0" />)</p>
<p><b>主要应用</b>:
<ul>
<li><u>数据验证</u>; 这是正则表达式在开发中最常见的应用, 通过测试字符串内的模式。来验证输入的字符串是否为邮政编码, 电话号码, 电子邮件地址, 信用卡号码等等。</li>
<li><u>搜索和替换文本</u>; 用正则表达式来搜索文档中的特定文本块, 根据需要用其他指定的文本块进行替换。这也是文本编辑中的一个常见应用, 如将网页中的HTML代码转化为UBB代码.</li>
</ul>
<p>既然发在『软件使用』板, 正则表达式的开发中的应用就不介绍了, 以下仅以EmEditor中的正则表达式来作介绍:</p>
<p><u>1. 启用正则表达式</u></p>
<p>菜单: Search  &#8211; Find (Replace) &#8211; 选中 Use Regular Expressions</p>
<p><u>2. Emeditor 正则语法</u></p>
<p>正则表达式是普通字符和元字符组合的一种模式. 它的结构与算术表达式的结构类似, 各种元字符和运算符可以将小的表达式组合起来，创建大的表达式。通过在一对分隔符之间放置表达式模式的各种组件，就可以构建正则表达式。</p>
<p><i>2.1 普通字符</i><br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">普通字符是指除了 &#8220;.&#8221;, &#8220;*&#8221;, &#8220;?&#8221;, &#8220;+&#8221;, &#8220;(&#8220;, &#8220;)&#8221;, &#8220;{&#8220;, &#8220;}&#8221;, &#8220;[", "]&#8220;, &#8220;^&#8221;, &#8220;$&#8221; 和 &#8220;\&#8221; 这些特殊字符之外的所有其他字符. 而这些特殊字符也可以通过前面加上&#8221;\&#8221;前缀而变为普通字符. 比如, 搜索&#8221;CCF&#8221;即为在文本中匹配所有的&#8221;CCF&#8221;字符串, 搜索&#8221;\[CCF\]&#8220;则是在文本中匹配所有的&#8221;[CCF]&#8220;字符串.</p>
<p>简而言之, 普通字符即为只匹配自身的字符.</p></blockquote>
<p><i>2.2 元字符</i><br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">元字符不匹配其自身，它用特殊方式来解析从而实现更多的逻辑功能。正则表达式通过元字符在模式中包含选择和循环</p></blockquote>
<p><u><i>2.2.1 特殊字符</i></u></p>
<ul>
<li><font color="Blue">.</font> 匹配除换行符 \n 之外的任何单个字符。</li>
<li><font color="Blue">( )</font> 分组捕获(子表达式)的开始和结束。可以捕获子表达式以供以后使用。</li>
<li><font color="Blue">[ ]</font> 中括号表达式的开始。<br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">中括号表达式是在方括号内包含一个或多个字符构成的列表的表达式。普通字符在中括号内表示本身，大多数特殊字符在中括号表达式内出现时失去它们的意义。除了转义字符&#8217;\', (要包含&#8217;\', 需要使用&#8217;\\&#8217;) 如: 正则表达式 No [1234] 匹配 No 1, No 2, No 3 和 No 4.</p>
<p>如果想在中括号中使用一个范围作为列表来匹配字符，可以用连字符 &#8216;-&#8217; 将范围中的开始字符和结束字符分开。单个字符的字符值确定范围内的相对顺序。如: 正则表达式 No [1-4] = No [1234]</p>
<p>注意 1. 开始值的Unicode值必须在结束值Unicode值的前面。</p>
<p>注意 2. [\-]匹配连字符&#8217;-', 放在中括号列表的开始或结尾也可起到同样的效果, 如 [-c-f] 匹配 c 至 f 的字符和连字符</p>
<p>如果需要匹配不属于列表或范围内的任何字符，可以在列表开头加上&#8217;^'前缀。如: 正则表达式 No [^1-4] 匹配 No 5 和更大的编号.</p>
<p>中括号表达式还可进行组合, 如 [A-Za-z0-9] 匹配A-Z, a-z, 0-9 的字符
</p></blockquote>
</li>
<li><font color="Blue">\ </font> 将下一字符标记为特殊字符、文本、反向引用或八进制转义符。例如，<br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">字符 n 匹配字符 n</p>
<p>\n 匹配换行符</p>
<p>序列 \\ 匹配 \</p>
<p>序列 \( 匹配 (
</p></blockquote>
</li>
<li><font color="Blue">| </font> 替换字符, 对|左右的两个项分别匹配进行选择。或者说, 就是逻辑的OR的概念</li>
<li><font color="Blue">{ }</font> 标记限定符表达式的开始。<br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">(数量)限定字符</p>
<p>限定字符能够指定正则表达式的某个部分必须出现的次数
<ul>
<li><font color="Green">*</font>  零次或多次匹配前面的字符或子表达式。如，c*f 可以匹配 f 和 ccf。*  =  {0,}</li>
<li><font color="Green">+</font>  一次或多次匹配前面的字符或子表达式。如，c+f 可以匹配 cf 和 ccf，但不匹配 f。+ = {1,}</li>
<li><font color="Green">?</font>  零次或一次匹配前面的字符或子表达式。如，cc?f 可以匹配 cf 或 ccf。? = {0,1}</li>
<li><font color="Green">{n}</font> n 是非负整数。正好匹配 n 次。如，c{2}f 可以匹配 ccf。</li>
<li><font color="Green">{n,}</font> n 是非负整数。至少匹配 n 次。如，c{2,}f 不匹配 cf，而可以匹配 ccccccf。c{1,} = c+。c{0,} = c*</li>
<li><font color="Green">{n,m}</font> m 和 n 是非负整数，其中 n &lt;= m。至少匹配 n 次，至多匹配 m 次。如，c{1,3} 可以匹配 ccf 中的cc。c{0,1} 等效于 c?。</li>
</ul>
</blockquote>
</li>
</ul>
<p><u><i>2.2.2 控制字符</i></u><br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">
<ul>
<li><font color="Blue">\a</font> Bell 字符。= 0&#215;07</li>
<li><font color="Blue">\f</font> 换页符匹配。= 0x0C</li>
<li><font color="Blue">\n</font> 换行符匹配。= 0x0A</li>
<li><font color="Blue">\r</font> 匹配一个回车符。= 0x0D
</li>
<li><font color="Blue">\t</font> 制表符匹配。= 0&#215;09</li>
<li><font color="Blue">\v</font> 垂直制表符匹配。= 0x0B</li>
<li><font color="Blue">\e</font> ASCII 换码字符。= 0x1B</li>
<li><font color="Blue">\0dd</font> 八进制换码字符, dd代表八进制数字。</li>
<li><font color="Blue">\xXXXX或\x{XXXX}</font> 4位十六进制Unicode字符, XXXX代表十六进制数字。
</li>
<li><font color="Blue">\cZ Z-&#8217;@&#8217;</font>  控制字符Control-Z, Z为大于等与&#8221;@&#8221;的ASCII字符</li>
</ul>
</blockquote>
<p><i><u>2.2.3 换码字符</u></i><br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">
<ul>
<li><font color="Blue">\w</font> 任一单词字符, 如A-Z, a-z, 0-9, _等, 如 \w\w\w可以匹配 U_4 但不匹配 %^e</li>
<li><font color="Blue">\W</font> 任一非单词字符, 如 \W\W 可以匹配 *&amp; 但不匹配 7#</li>
<li><font color="Blue">\s</font> 任一空白字符，包括空格、制表符、换页符、回车符和垂直制表符。= [ \f\n\r\t\v]</li>
<li><font color="Blue">\S</font> 任一非空白字符. = [^ \f\n\r\t\v]</li>
<li><font color="Blue">\d</font> 0-9的任一数字字符, 如 \d\d可以匹配 54 但不匹配 a4</li>
<li><font color="Blue">\D</font> 任一非数字字符. 如 \D\D可以匹配 a4 但不匹配 54</li>
<li><font color="Blue">\l</font>  a-z 之间的任一小写字符, 如 \l\l\l可以匹配 ccf 但不匹配 ccF</li>
<li><font color="Blue">\L</font> 任一非小写字符, 如 \L\L\L可以匹配 CCF 但不匹配 cCF</li>
<li><font color="Blue">\u</font> a-z 之间的任一大写字符, 如 \u\u\u可以匹配 CCF 但不匹配 CCf</li>
<li><font color="Blue">\U</font> 任一非大写字符, 如 \U\U\U可以匹配 ccf 但不匹配 ccF</li>
<li><font color="Blue">\C</font> 任一字符, = &#8216;.&#8217;</li>
<li><font color="Blue">\Q</font> 前置引号符, 其后的任意字符均被认为普通字符直至出现后置引号符\E. 同时匹配单引号和双引号</li>
<li><font color="Blue">\E</font> 后置引号符</li>
</ul>
</blockquote>
<p><u><i>2.2.4 转义字符串</i></u></p>
<p>表示为[:classname:], 如&#8221;[[:space:]]&#8221;表示所有的空格字符</p>
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;"><ul>
<li><font color="Blue">alnum</font> 任一单词字符和数字字符.  = [\w\d]</li>
<li><font color="Blue">alpha</font> 任何一个单词字符, 如A-Z, a-z, 0-9</li>
<li><font color="Blue">blank</font> 任一空白字符，包括空格、制表符、换页符、回车符和垂直制表符。= [ \f\n\r\t\v] = \s</li>
<li><font color="Blue">cntrl</font> 任一控制字符.</li>
<li><font color="Blue">digit</font> 0-9的任一数字字符, = \d</li>
<li><font color="Blue">graph</font> 任一图形字符.</li>
<li><font color="Blue">lower</font> a-z 之间的任一小写字符 =\l</li>
<li><font color="Blue">print</font> 任一可打印字符 = &#8216;.&#8217; = \C</li>
<li><font color="Blue">punct</font> 任一标点符号</li>
<li><font color="Blue">space</font> 任一空格字符</li>
<li><font color="Blue">upper</font> a-z 之间的任一大写字符 = \u</li>
<li><font color="Blue">xdigit</font> 4位十六进制Unicode字符, = \xXXXX</li>
<li><font color="Blue">word</font> 任何一个单词字符, 如A-Z, a-z, 0-9, _等, = \w</li>
<li><font color="Blue">unicode</font> 任何一个ASCII值大于255的字符</li>
</ul>
</blockquote>
<p><u><i>2.2.5 定位字符</i></u></p>
<p>定位字符可以把正则表达式固定到行首或行尾。在Perl正则全集中还能使正则表达式出现在一个单词内、在一个单词的开头或者一个单词的结尾, emeditor只是一个子集, 不包含这个功能。<br />
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;">
<ul>
<li><font color="Blue">^</font> 匹配输入字符串开始的位置。如果设置customize中的&#8221;regular expressions can match new line characters&#8221;，那么 ^ 还匹配 \n 或 \r 后面的位置。 但在中括号表达式中使用的情况除外，在那种情况下它对字符集求反。</li>
<li><font color="Blue">$</font> 匹配输入字符串结尾的位置。如果设置customize中的&#8221;regular expressions can match new line characters&#8221;，那么 $ 还匹配 \n 或 \r 前面的位置。</li>
</ul>
</blockquote>
<p><u>3. 分组捕获和替换</u></p>
<p>分组通常用来捕获特定模式的一组文本, 并用与之后的替换操作, 这也就是将分组和替换结合起来讲解的原因. </p>
<p>最基本的分组构造方式就是(),在左右括号中括起来的部分，就是一个分组；在正则全集中还有如(?&lt;name&gt; )的命名分组方式，这种方式组合了模式在就是对分组的部分进行了命名，这样就可以通过该组的命名来获取信息, 但这种方式在emeditor中不被支持. 以下分别来介绍各种不同的分组:</p>
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;"><ul>
<li><font color="Blue">()</font> <b>组捕获</b>. 这种分组对模式在括号内所捕获的字符进行组合, 并且每个分组捕获的匹配结果都将保存为一个实体以备其后的操作所引用. 甚至在正则全集中还可对前面的分组进行反向引用(这是题外话, emeditor不支持). 举例说明:</p>
<p>源文本:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">site status- online members: 65, online guests: 12</div></td></tr></tbody></table></div>
</div>
<p>使用正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(members|guests): \d+</div></td></tr></tbody></table></div>
</div>
<p>括号中有两个可能的匹配: members 和 guests, 只需要匹配其中任意一个; 其后是冒号和一个空格, 最后匹配至少一个数字. 匹配模式结果如下:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members: 65<br />
guests: 12</div></td></tr></tbody></table></div>
</div>
<p>其中members和guests在两次匹配中被捕捉, 可以在随后的操作中引用.
</li>
<li><font color="Blue">(?<img src="images/smilies/Default/dft009.gif" alt="" title="Smile" class="inlineimg" border="0" /></font> <b>非组捕获</b>. 这种分组仅仅对模式在括号内所匹配的字符进行组合, 模式所匹配的字符将不会作为一个组来捕获. 虽然他也同样成为最终的匹配结果的一部分, 但无法为其后的操作所引用. 同样以上例继续:
<p>使用正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(?:members|guests): \d+</div></td></tr></tbody></table></div>
</div>
<p>匹配模式结果同样为:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members: 65<br />
guests: 12</div></td></tr></tbody></table></div>
</div>
<p>但是members和guests仅仅在两次匹配中被分组, 并不被捕获, 也不可以在随后的操作中引用.</p>
<p>使用非捕获组有其原因和场合. 其一, 从效率上说, 捕获一个分组需要消耗额外的资源和处理时间, 所以不应该捕获不需要使用的数据. 其二, 对模式中有多个捕获组的情况, 对不需要处理的分组进行捕获只会对分组信息造成混乱. 其三, 避免不需要贪婪匹配的场合发生贪婪匹配, 贪婪匹配是正则引擎的一个重要特性, 要说清楚其机理可能还需要另外开一个专题了. 对这一点, 还以上例说明一下:</p>
<p>使用不带分组的正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members|guests: \d+</div></td></tr></tbody></table></div>
</div>
<p>匹配模式为:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members<br />
guests: 12</div></td></tr></tbody></table></div>
</div>
<p>这个正则表达式的问题在于, 他匹配的是&#8221;members&#8221; 或 &#8220;guests: \d+&#8221;, 这是模式中贪婪&#8221;消费&#8221;字符引起的. 而通过增加括号进行分组, 使正则引擎将两个匹配选项作为一个组处理, 从而正确匹配其中的一个匹配项.
</li>
<li><font color="Blue">(?=)</font> <b>正声明组, 非捕获</b>. 此分组中的模式必须出现在声明的右侧, 并且, 这个模式不构成匹配结果的一部分. 举例:
<p>源文本:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">site status- online members: 65, online guests: 12</div></td></tr></tbody></table></div>
</div>
<p>使用正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">\S+(?=\s\d+)</div></td></tr></tbody></table></div>
</div>
<p>此模式中规定了\s\d+必须出现在\S+声明的右侧. 也就是说, 在至少一个非空格字符(声明)的右侧必须出现一个空格字符和至少一个数字, 而且只有这个声明构成匹配结果. 匹配模式结果如下:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members:<br />
guests:</div></td></tr></tbody></table></div>
</div>
<p>这两次匹配中不被捕捉.
</li>
<li><font color="Blue">(?!)</font> <b>负声明组, 非捕获</b>. 此分组中的模式不得出现在声明的右侧, 并且, 这个模式不构成匹配结果的一部分. 还是用上面的例子:
<p>使用正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">\d{2}(?!,)</div></td></tr></tbody></table></div>
</div>
<p>此模式中规定了&#8221;,&#8221;不得出现在\d{2}声明的右侧. 也就是说, 在连续两个数字(声明)的右侧不得出现逗号才能被匹配. 匹配模式结果如下:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">12</div></td></tr></tbody></table></div>
</div>
<p>这两次匹配中不被捕捉.</li>
</ul>
</blockquote>
<p>严格的说, 后面两个分组不能称之为分组, 他们只是模式声明, 他们不能成为匹配结果, 也不能被捕获. 在正则全集中, 还有反向声明分组(?<=)(?<!)和非回溯分组(?>), 在emeditor中不被支持.</p>
<p>说到括号的功能, 本来正则中的一个重要指令-条件指令和分组内联设定是不得不说的, 可惜的是&#8230; emeditor也同样不支持~~~~</p>
<p>在前面的例子中一直提到匹配之后的操作, 而这个进一步的操作最常见的就是替换. 先继续上面的例子:</p>
<p>源文本:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">site status- online members: 65, online guests: 12</div></td></tr></tbody></table></div>
</div>
<p>使用搜索正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(members|guests)</div></td></tr></tbody></table></div>
</div>
<p>和替换正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ccf-\1</div></td></tr></tbody></table></div>
</div>
<p>匹配模式结果如下:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members<br />
guests</div></td></tr></tbody></table></div>
</div>
<p>替换后的文本为:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">site status- online ccf-members: 65, online ccf-guests: 12</div></td></tr></tbody></table></div>
</div>
<p>其中members和guests在两次匹配中被捕捉, 在随后被引用, 并添加ccf-前缀后替换源文本中的匹配字符.</p>
<p>在匹配模式中的分组匹配结果将按前后顺序被正则引擎分别赋予内部组号, 在替换操作中就可以用\加上这个组号来引用相应的匹配结果. 继续上例:</p>
<p>使用搜索正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(members|guests): (\d{2})</div></td></tr></tbody></table></div>
</div>
<p>和替换正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ccf-\1 = \2</div></td></tr></tbody></table></div>
</div>
<p>匹配模式结果如下:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">members: 65<br />
guests: 12</div></td></tr></tbody></table></div>
</div>
<p>替换后的文本为:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">site status- online ccf-members = 65, online ccf-guests = 12</div></td></tr></tbody></table></div>
</div>
<p>在emeditor的正则子集中增加了一个特殊的引用: \0 , \0 将引用上次的匹配结果, 继续把:</p>
<p>使用搜索正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">\d{2}</div></td></tr></tbody></table></div>
</div>
<p>和替换正则表达式:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">*\0*</div></td></tr></tbody></table></div>
</div>
<p>匹配模式结果如下:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">65<br />
12</div></td></tr></tbody></table></div>
</div>
<p>替换后的文本为:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<div class="codecolorer-container text mac-classic alt2" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">site status- online ccf-members: *65*, online ccf-guests: *12*</div></td></tr></tbody></table></div>
</div>
<p>作为一个编辑软件, emeditor的正则子集中增加了一些替换修饰符:</p>
<blockquote style="border-left:2px solid #DDDDDD; margin:15px 30px 0 10px; padding-left:20px;"><ul>
<li><font color="Blue">\U</font> 大写修饰. 将其后的所有的字符替换为大写</li>
<li><font color="Blue">\L</font> 小写修饰. 将其后的所有的字符替换为小写</li>
<li><font color="Blue">\H</font> 半角修饰. 将其后的所有的字符替换为半角字符. 写到这里, 不得不称许一下emeditor对中文的良好支持, 这个\H至少我是很常用的, 不喜欢看到文本里面都是些１２３ａｂｃ之类的全角字符&#8230;</li>
<li><font color="Blue">\F</font> 全角修饰. 将其后的所有的字符替换为全角字符</li>
<li><font color="Blue">\E</font> 关闭之前的\U, \L, \H, \F修饰.</li>
</ul>
</blockquote>
</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/regular-expressions-in-emeditor.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Grep书签</title>
		<link>http://iregex.org/blog/grep-bookmarks.html</link>
		<comments>http://iregex.org/blog/grep-bookmarks.html#comments</comments>
		<pubDate>Sun, 08 Feb 2009 15:43:16 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[grep]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=56</guid>
		<description><![CDATA[Grep是终端下一款好用的正则表达式工具，其全名是lobal search regular expression(RE) and print out the line，它最直接的功能是搜索具有指定正则表达式模式的文本文件。当然还可以在不同的场合下有不同... ]]></description>
			<content:encoded><![CDATA[<p>Grep是终端下一款好用的正则表达式工具，其全名是lobal search regular expression(RE) and print out the line，它最直接的功能是搜索具有指定正则表达式模式的文本文件。当然还可以在不同的场合下有不同的功用。例如，在ubuntu下，我经常使用类似于这样的命令(在windows下，搜索NTFS分区中的文件，我使用<a target="_blank" href="http://xbeta.info/everything-search-tool.htm">Everything</a>，它是速度最快的文件搜索软件，不过只搜索文件名，不搜索文件内容，支持正则表达式)：</p>
<p>find | grep -E &#8216;(mp3|wma)$&#8217;</p>
<p>该命令的作用是，以递归的方式寻找当前目录下所有的mp3、wma文件，打印出完整的路径。之所以不用ls，是因为ls不能显示完整路径。之所以在grep后面加&#8221;-E&#8221;，是为了使用更完整的正则表达式的支持。</p>
<p>我推荐的关于GREP的链接如下：<br />
<span id="more-56"></span></p>
<ul>
<li>关于GREP的描述，可以参考百度百科之GREP条：<a target="_blank" href="http://baike.baidu.com/view/1057278.htm">http://baike.baidu.com/view/1057278.htm</a>，它介绍了GREP的元字符集、用于egrep和 grep -E的元字符扩展集、POSIX字符类、 Grep命令选项，以及一些实例。</li>
<li>如果您不介意读一点英文，可以看一下wiki词条：<a target="_blank" href="http://en.wikipedia.org/wiki/Grep">http://en.wikipedia.org/wiki/Grep</a>，本词条没有上面的百度词条丰富，但是条理清晰，也可一读。</li>
<li>官方网站：<a target="_blank" href="http://www.gnu.org/software/grep/">http://www.gnu.org/software/grep/</a>。</li>
<li>电子书：<span class="content">Oreilly.Grep.Pocket.Reference.Jan.2009，英文PDF，共79页。<a href="http://is.gd/ijyT">请点击链接直接下载此书</a>。</span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/grep-bookmarks.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RegexBuddy3.2.1完全版</title>
		<link>http://iregex.org/blog/regexbuddy321.html</link>
		<comments>http://iregex.org/blog/regexbuddy321.html#comments</comments>
		<pubDate>Sat, 10 Jan 2009 18:46:42 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[just great software]]></category>
		<category><![CDATA[regexbuddy]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=53</guid>
		<description><![CDATA[感谢网友WNlord提供信息，我有幸下载到了RegexBuddy当前的最新版3.2.1。该版本是零售完全版，可以做生成Portable Installation。不知道RegexBuddy功能的请自行站内搜索。下载地址见文章末尾。 下载地址... ]]></description>
			<content:encoded><![CDATA[<p>感谢网友WNlord提供信息，我有幸下载到了RegexBuddy当前的最新版3.2.1。该版本是零售完全版，可以做生成Portable Installation。不知道RegexBuddy功能的请自行站内<a href="http://iregex.org/blog/tag/regexbuddy">搜索</a>。下载地址见文章末尾。<br />
<span id="more-53"></span><br />
<strong>下载地址：</strong></p>
<ul>
<li><a href="http://zhasm.com/downloads#regexbuddy3.2.1" target="_blank">深柳堂</a></li>
<li><a href="http://www.3ddown.com/soft/25208.htm" rel="nofollow" target="_blank">精品软件园</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/regexbuddy321.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>正则式软件中的TotalCMD：RegexBuddy</title>
		<link>http://iregex.org/blog/regexbuddy320.html</link>
		<comments>http://iregex.org/blog/regexbuddy320.html#comments</comments>
		<pubDate>Fri, 26 Dec 2008 18:39:08 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[regexbuddy]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=46</guid>
		<description><![CDATA[之前我爱正则表达式已经介绍过，RegexBuddy 是windows下（在linux下可以使用wine调用）一款超强的正则式辅助编写软件。在它的帮助下，你可以轻松编写你所需要的正则表达式，清晰地理解别人写... ]]></description>
			<content:encoded><![CDATA[<p><a href="http://iregex.org/blog/regexbuddy320.html" target="_blank" title="http://iregex.org|我爱正则表达式"><img src="http://i293.photobucket.com/albums/mm60/zhasm/regexbuddy320.png" border="0" alt="regexbuddy 3.2.0" alt="我爱正则表达式RegexBuddy Logo"></a></p>
<p>之前<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">我爱正则表达式</a>已经介绍过，RegexBuddy 是windows下（在linux下可以使用wine调用）一款超强的<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则式</a>辅助编写软件。在它的帮助下，你可以轻松编写你所需要的<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则表达式</a>，清晰地理解别人写的<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则表达式</a>，快速测试<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则式</a>与目标文本或文件是否匹配并避免出现错误。它能帮你把<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则表达式</a>转换成你所需要的编程语言的格式，帮你收集并详细记录<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则式</a>代码库，以便将来重新使用。它还能与你最喜欢的搜索工具、编辑器集成在一起，招之即来。在我所有使用过的<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则式</a>软件中，以RegexBuddy为最强，称之为<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则式</a>软件中的<a target="_blank" href="http://xbeta.info/tag/totalcommander">TotalCMD</a>，毫不为过。</p>
<p>原来本站以留言索取的形式，向诸位同好提供过3.1.0版。在网友<strong>那个谁</strong>的协助下，我得到了更新一点的版本，3.2.0，附在文末，请按需下载。 </p>
<p><span id="more-46"></span></p>
<p>3.2.0版的RegexBuddy的主要更新有（2008年10月4日）： </p>
<ul>
<li>在拷贝、粘贴菜单：在JavaScript operator的基础之上加入了 JavaScript string 选项。R语言使用与JavaScript相同语法的字串。 </li>
<li>在拷贝、粘贴菜单：加入PowerShell字串支持。支持单引号字串，双引号字串，以及Here字串。 </li>
<li>增加了对PowerShell、R 语言的支持。 </li>
</ul>
<p>3.2.1版的RegexBuddy的主要更新有（2008年12月9日）： </p>
<ul>
<li>HTML导出时不再输出无用的滚动条。 </li>
<li>将<a href="http://iregex.org" title="http://iregex.org|我爱正则表达式" target="_blank">正则式</a>转换为Perl风格时，字符类里面的美元符总是被转义，以免出现语义混淆。 </li>
</ul>
<p>当然，每次更新都少不了一大堆的Bug Fix。</p>
<p>完整的更新历史可以参阅<a target="_blank" href="http://www.regexbuddy.com/history.html" rel="nofollow">RegexBuddy官方的history文件</a>。</p>
<p>我手头的3.2.0版，其实是3.2.0的demo版安装文件，附了一个已经<strong>部分破解并压缩</strong>过的regexbuddy.exe文件。使用时只需要安装SetupRegexBuddyDemo.exe，然后将regexbuddy.exe替换掉新安装生成的RegexBuddy.exe。</p>
<ul>
<li>说它部分破解，是因为在About菜单中，依然显示Free Evaluation Version；无法安装Portable Version。 </li>
<li>说它压缩过，是因为原装的regexbuddy.exe为4+M，而绿色版的regexbuddy.exe为1+M。 </li>
<li>3.1.0完全版是现有的比较完美的版本，可以实现Portable Version。 </li>
</ul>
<p>相关链接：</p>
<ol>
<li><a target="_blank" href="http://www.regexbuddy.com/download.html">RegexBuddy官方网站</a>，US$39.95购买最新正版3.2.1。</li>
<li>下载<a target="_blank" href="http://zhasm.com/downloads#regexbuddy3.2">RegexBuddy3.2.0</a>微限版。 </li>
<li>下载<a target="_blank" href="http://zhasm.com/downloads#RegexBuddy3.1">RegexBuddy3.1.0</a>完全版。 </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/regexbuddy320.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PowerGREP3.50完全版下载</title>
		<link>http://iregex.org/blog/powergrep350.html</link>
		<comments>http://iregex.org/blog/powergrep350.html#comments</comments>
		<pubDate>Tue, 23 Dec 2008 14:28:39 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[powergrep]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[widnows]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=42</guid>
		<description><![CDATA[之前我爱正则表达式介绍过一款软件PowerGREP，并以留言索取的形式，向大家发放3.3.3版。今天，在热心网友astek的推荐下，rex下载到了PowerGREP的3.50版，这也是迄今为止的最新版。下载地址见文末... ]]></description>
			<content:encoded><![CDATA[<p><img src="http://i293.photobucket.com/albums/mm60/zhasm/powergrep350.jpg" /> </p>
<p>之前<a target="_blank" href="http://iregex.org">我爱正则表达式</a>介绍过一款软件PowerGREP，并以留言索取的形式，向大家发放3.3.3版。今天，在热心网友<strong>astek</strong>的推荐下，rex下载到了PowerGREP的3.50版，这也是迄今为止的最新版。下载地址见文末。</p>
<p>PowerGREP是一款正则式应用软件，它是grep或egrep的增强版，允许您以直观可视、可撤消的方式，在不同的文件夹内，对不同的文件进行批量的文本搜索、替换。当然，是正则表达式层面上的。详细的介绍可参考这篇文章：<a target="_blank" href="http://iregex.org/blog/powergrep.html">windows下的正则式工具介绍之二：powergrep</a>。该篇文章的评论功能已经关闭，如果对该软件有问题，可以在此留言，或集中至正则式中文论坛<a href="http://regex.me">http://regex.me</a>讨论。</p>
<p><span id="more-42"></span></p>
<p>根据官方的<a target="_blank" href="http://www.powergrep.com/history.html">history列表</a>，该版相对于3.3.3版，修复了N多的bugs，提供了许许多多的新特性，大致如下：</p>
<p><strong>3.40的新特性（2007年6月25日）：</strong></p>
<ul>
<li>File Selector: Refresh command that refreshes the list of available drive letters, marks all folders as needing to be globbed again, and immediately updates all expanded folder tree nodes. </li>
<li>Preferences, Encoding: Option to detect encoding based on the HTML Content-Type meta tag. </li>
<li>Preferences, Encoding: Option to preserve the presence/absence of the BOM in Unicode files. </li>
<li>Preferences, File Formats: Extensions of files to be treated as zip archives (*.zip, *.jar, etc.) and files to be treated as zip documents (*.docx, *.xlsx, *.odf, etc.) can now be configured. </li>
<li>Preferences, File Formats: Option to configure the extensions of file masks that determine which conversion filter will be used for which files. </li>
<li>Preferences, File Formats: Option to disable specific conversion filters (PDF, Word, Excel). </li>
<li>Preferences, File Formats: Option to specify a folder where converted PDF, Word and Excel files should be cached, along with a maximum size of the cache. Using the cache speeds up searching through PDF, Word and Excel files that were previously searched through with PowerGREP. The cache is shared between all running instances of PowerGREP. </li>
<li>Regex: Character class subtraction, as supported by XML schema and the .NET framework. </li>
<li>Regex: Free-spacing regex search type and (?x:) free-spacing mode modifier. </li>
<li>Regex: POSIX character classes. </li>
<li>Regex: <tt>\Q..\E</tt> escape sequence for escaping a string of metacharacters. </li>
<li>Regex: <tt>\cA</tt> through <tt>\cZ</tt> ASCII control characters Ctrl+A through Ctrl+Z; equivalent of <tt>\x01</tt> through <tt>\x1A</tt>; can be used inside and outside character classes. </li>
<li>Regex: <tt>\p{Arabic}</tt> through <tt>\p{Yi}</tt> tokens for matching any character in a particular Unicode script; <tt>\p{IsArabic}</tt> syntax also supported. </li>
<li>Regex: <tt>\p{InBasicLatin}</tt> through <tt>\p{InSpecials}</tt> tokens for matching any character in a particular Unicode block; <tt>\p{IsBasicLatin}</tt> and <tt>\p{BasicLatin}</tt> alternatives also supported; BasicLatin can also be written as Basic_Latin, Basic-Latin and Basic Latin. </li>
<li>Results: &quot;Totals&quot; option to show the number of matches per file and the clickable file header on one line. This halves the number of lines needed when not showing match details (e.g. after a &quot;quick execute&quot;), and leaves the total visible when collapsing file nodes. </li>
<li>Results: &quot;Totals&quot; option to show totals both at the top and the bottom. </li>
</ul>
<p><strong>3.42版的新特性（2008年1月18日）：</strong></p>
<ul>
<li>Action: Hexadecimal escapes like \xFF in the replacement text to insert non-printable characters. </li>
<li>Action: Unicode escapes \uFFFF and \x{FFFF} in the replacement text to insert characters that cannot be typed on the keyboard. </li>
<li>Command Line: Search through files found in a previously saved search with /markresults previousresults.pgr. This parameter has the same effect as the Mark Files with Results command in the File Selector menu. </li>
<li>Regex: Forward references (i.e. a backreference to a group defined after it) are now supported. E.g. <tt>(\2two|(one))+</tt> will match <tt>oneonetwo</tt> instead of triggering an error. </li>
<li>Setup: Create Portable Installation directly from the self-extracting setup. The Install on Removable Drive menu item in the Help menu was renamed for consistency. </li>
</ul>
<p><strong>3.50版的改进之处（2008年5月13日）：</strong></p>
<ul>
<li>Conversion manager: PowerGREP will now launch the conversion manager only when it&#8217;s needed, rather than when starting PowerGREP. </li>
<li>File Formats: PowerGREP now sets the file date on files inside compound documents to the same date as the overall document file. </li>
<li>File Selector/Results: Keyboard mnemonics (underlined letters) for the default items in the Edit File submenu. You can assign mnemonics to your custom editors by placing an ampersand before the character you want to use as the mnemonic. E.g. &quot;&amp;My Editor&quot; makes M the mnemonic. </li>
<li>Results, Export: When exporting to HTML, file references that are clickable in PowerGREP are now also clickable in the HTML output. </li>
<li>Results: Use base64Binary instead of hexBinary to save match data into .pgr files, resulting in a 33% size savings for match data. </li>
</ul>
<p>由此可见，其更新是相当多，即使在介面上不是很明显。很值得下载。</p>
<p><a href="http://zhasm.com/downloads#powergrep.3.5" target="_blank">下载地址：深柳堂</a>|<a href="http://www.3ddown.com/soft/19804.htm" target="_blank">精品软件园</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/powergrep350.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Windows下的正则表达式工具之五——经典的Regulator</title>
		<link>http://iregex.org/blog/regulator.html</link>
		<comments>http://iregex.org/blog/regulator.html#comments</comments>
		<pubDate>Wed, 17 Dec 2008 15:55:44 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[expresso]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regexbuddy]]></category>
		<category><![CDATA[regulator]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=40</guid>
		<description><![CDATA[本文介绍的the Regulator 2.0 与上一篇文章介绍的Expresso一样，都是颇有年头的软件：Expresso的最后更新日期似乎是2007年6月30日；the Regulator 2.0的上次更新，更是可追溯到2004年。可是，在没有RegexBudd... ]]></description>
			<content:encoded><![CDATA[<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i293.photobucket.com/albums/mm60/zhasm/regulator_logo.png"> 本文介绍的the Regulator 2.0 与上一篇文章介绍的<a href="http://iregex.org/blog/expresso.html" title="Expresso|http://iregex.org|我爱正则表达式" target="_blank">Expresso</a>一样，都是颇有年头的软件：Expresso的最后更新日期似乎是2007年6月30日；the Regulator 2.0的上次更新，更是可追溯到2004年。可是，在没有RegexBuddy的日子里，the Regulator 可算是元老呢！MSDN上有篇文章《<a target="_blank" href="http://msdn.microsoft.com/zh-cn/magazine/cc300497(en-us).aspx">Ten Must-Have Tools Every Developer Should Download Now</a>》，介绍了开发者必备的10款工具之一就有the <a href="http://iregex.org/blog/regulator.html" title="Regulator|http://iregex.org|我爱正则表达式" target="_blank">Regulator</a>。作者<a target="_blank" href="http://weblogs.asp.net/rosherove/">Roy Osherove</a>在regulator的帮助文件中说，自己的Regulator的创意就来自于<a href="http://iregex.org/blog/expresso.html" title="Expresso|http://iregex.org|我爱正则表达式" target="_blank">Expresso</a>。</p>
<p><a href="http://iregex.org/blog/regulator.html" title="Regulator|http://iregex.org|我爱正则表达式" target="_blank">Regulator</a>的界面，比<a href="http://iregex.org/blog/expresso.html" title="Expresso|http://iregex.org|我爱正则表达式" target="_blank">Expresso</a>要新潮，与以前介绍过的Mtracer有几分相像。<span id="more-40"></span>看界面：<img src="http://i293.photobucket.com/albums/mm60/zhasm/regulator_main.png" width=540> </p>
<p>与<a href="http://iregex.org/blog/expresso.html" title="Expresso|http://iregex.org|我爱正则表达式" target="_blank">Expresso</a>一样，它同样支持.Net版的正则，支持将正则式导出为VB或C#格式。比起<a href="http://iregex.org/blog/expresso.html" title="Expresso|http://iregex.org|我爱正则表达式" target="_blank">Expresso</a>来，它的亮点之一是正则式部分支持语法高亮显示。</p>
<p><a href="http://iregex.org/blog/regulator.html" title="Regulator|http://iregex.org|我爱正则表达式" target="_blank">Regulator</a>有一个功能是网络搜索，即支持在软件界面上直接搜索regexlib.com上的正则代码库。这原本应该是个很实用的功能。可惜的是，我在多种情况下（代理）试用了该功能，一直不能返回搜索结果。或许是随着时间的迁移，regexlib.com更换了查询输出接口，而<a href="http://iregex.org/blog/regulator.html" title="Regulator|http://iregex.org|我爱正则表达式" target="_blank">Regulator</a>还站在望夫涯上，傻傻地使用原来的方式与regexlib.com通讯，自然接收不到任何反馈。</p>
<p>帮助文件中的搜索结果列表：<br /><img src="http://i293.photobucket.com/albums/mm60/zhasm/regulator_search_old.png"> </p>
<p>这是在我的机器上返回的空列表：<br /><img src="http://i293.photobucket.com/albums/mm60/zhasm/regulator_search.png"> </p>
<p>我登录到作者<a target="_blank" href="http://weblogs.asp.net/rosherove/">Roy Osherove</a>的博客，搜索到他的一些其它正则式项目，例如2006年10月份的<a target="_blank" href="http://weblogs.asp.net/rosherove/archive/2006/10/09/Regulazy-1.0.3-Released.aspx">Realazy</a>（将普通文本转换为正则表达式的小工具，比较傻瓜），2005年11月份的VS2005下的正则式可视化工具（<a target="_blank" href="http://weblogs.asp.net/rosherove/archive/2005/11/26/AnnoucingRegexKit10.aspx">Regular Expression Visualizers for VS 2005</a>），只可惜最近两年没有在正则式方面更新文章或软件。因此该软件估计以后也不会更新了吧。作为一款经典的免费的正则式软件，估计<a href="http://iregex.org/blog/regulator.html" title="Regulator|http://iregex.org|我爱正则表达式" target="_blank">Regulator</a>曾经风光一时；不过，在我接触正则式时起，一直用的就是Regex了。</p>
<p>最近搜集了一大堆网页正则式工具，有时间跟大家分享一下。敬请期待。 </p>
<p>附：the Regulator 2.0 (3.2MB)下载地址：via <a href="http://downloads.sourceforge.net/regulator/Regulator20Bin.zip?modtime=1189740236&#038;big_mirror=0" title="the Regulator|http://iregex.org/|我爱正则表达式">sourceforge</a> | via <a href="http://zhasm.com/downloads#regulator" target="_blank">深柳堂</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/regulator.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows下的正则表达式工具之四——强大而免费的Expresso</title>
		<link>http://iregex.org/blog/expresso.html</link>
		<comments>http://iregex.org/blog/expresso.html#comments</comments>
		<pubDate>Sat, 13 Dec 2008 03:43:21 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[expresso]]></category>
		<category><![CDATA[regexbuddy]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=39</guid>
		<description><![CDATA[曾经沧海难为水，除却巫山不是云。用过了RegexBuddy，再用其它的正则式辅助软件，总有些不习惯。然而本人幸好不是固步自封之辈，任何时候都勇于尝试新工具，体验新特征。这不，最近知道... ]]></description>
			<content:encoded><![CDATA[<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" alt="Expresso|http://iregex.org|我爱正则表达式" src="http://i293.photobucket.com/albums/mm60/zhasm/expresso.png" /> 曾经沧海难为水，除却巫山不是云。用过了<a title="regexbuddy" target="_blank" href="http://iregex.org/blog/regexbuddy.html">RegexBuddy</a>，再用其它的正则式辅助软件，总有些不习惯。然而本人幸好不是固步自封之辈，任何时候都勇于尝试新工具，体验新特征。这不，最近知道了<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>，第一时间就想体验一把，将感受写在这里。</p>
<p><span id="more-39"></span></p>
<p>首先说一下对<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>的印象。该软件理所应当支持了许多正则式功能，包括匹配、替换、分隔、分析，等等。不过，<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>是以.Net为基础的，因此其正则式是.Net风格的。（《<a href="http://iregex.org/blog/mastering-regular-expressions-3rd-pdf-ebook-download.html" title="精通正则表达式第三版|http://iregex.org|我爱正则表达式" target="_blank">精通正则表达式第三版</a>》里，第9章整整一章是讲.Net正则表达式的；在《<a href="http://iregex.org/blog/regular-expression-pocket-reference.html" title="Regular Expression Pocket Reference|http://iregex.org|我爱正则表达式">Regular Expression Pocket Reference</a>》里，同样也有一章，列出了.Net/C#正则表达式的风格列表。）<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>只支持将正则式导出为.Net的C#/Visual Basic/C++/CLI语言格式。比起RegexBuddy丰富的字符串风格、多语法风格，<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>显得有些简陋。<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>不支持语法高亮，或许是作者不喜欢使用richedit之故？无论匹配与否，输出框里全是一色的黑白色，着实有些乏味。<img src="http://i293.photobucket.com/albums/mm60/zhasm/expresso_testmode.png" width=540/> </p>
<p>不过，<a href="http://iregex.org/blog/expresso.html" target="_blank" title="Expresso|http://iregex.org|我爱正则表达式">Expresso</a>也并非毫无亮点。</p>
<ul>
<li>支持特殊字符：它支持在正则表达式中插入各种稀奇古怪的字符，当然，我这里指得的是有图形面板的支持，好让你知道你是在做什么。 </li>
<li>捕获：允许使用多种风格的捕获，包括命名捕获。没办法，这是.Net的特性。 </li>
<li>控制字符：它支持在正则表达式中插入多种控制字符，包括响铃(bell \a)、new line、vertical tab&#8230;&#8230; </li>
<li>排除匹配(Exclude Match)：即允许你选定一部分正则表达式，从而在匹配时略过该段正则式，就像它不存在一样。我觉得这一特性很实用，尤其是在调试时，你不必先删除再比较，只需将其选定即可。 <img src="http://i293.photobucket.com/albums/mm60/zhasm/expresso_designmode.png" width=540/> </li>
<li>批量验证(Validate)。你可以写一条正则式(Email、URL、变量名，等等)，然后将一大堆待验证的文本行贴至输入栏，检验其是否合法。 </li>
<li>语法分析树：它的语法分析树也很有意思。虽然也是黑白色的，但是层次很清晰。 </li>
<li>实用的可扩展的<strong>正则式锦囊</strong>(expression library)。 <img src="http://i293.photobucket.com/albums/mm60/zhasm/expresso_library.png" width=540/> </li>
<li>测试计时(Timing Tests)很有用的特性，帮助你测试单次匹配时间，以及多次匹配时间。<img src="http://i293.photobucket.com/albums/mm60/zhasm/expresso_timing_tests.png" /> </li>
<li>将正则表达式编译到文件中。或许对有特定需要的人有用吧。我从未使用C++/C#编写过需要正则表达式的程序，也没想到在程序中调用含有正则表达式的dll文件，因此该功能对我用处不大。 </li>
<li>它是<strong>免费</strong>的！虽然它需要注册，但是注册不需花钱，只需要按照提示，给作者发一封邮件即可，将你的全名告诉作者，你就会收到一封自动回复的Email，包括你的全名和以此生成的注册码。作者的本意其实是想统计一下，究竟有多少人在使用自己的软件。 </li>
</ul>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">相关链接</h2>
<ul>
<li><a title="Expresso官方网站|http://iregex.org|我爱正则表达式" href="http://www.ultrapico.com/">Expresso官方网站http://www.ultrapico.com/</a> </li>
<li><a title="Expresso|http://iregex.org|我爱正则表达式" target="_blank" href="http://www.ultrapico.com/App/Register.aspx" rel="nofollow">注册地址</a></li>
<li><a title="Expresso|http://iregex.org|我爱正则表达式" target="_blank" href="http://www.ultrapico.com/ExpressoSetup3.msi" rel="nofollow">ExpressoSetup3.0</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/expresso.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>windows下的正则式工具介绍之三：MTracer2.0介绍以及与RegexBuddy比较</title>
		<link>http://iregex.org/blog/mtracer-vs-regexbuddy.html</link>
		<comments>http://iregex.org/blog/mtracer-vs-regexbuddy.html#comments</comments>
		<pubDate>Tue, 16 Sep 2008 03:29:13 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[chinese]]></category>
		<category><![CDATA[mtracer]]></category>
		<category><![CDATA[powergrep]]></category>
		<category><![CDATA[regexbuddy]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=32</guid>
		<description><![CDATA[RegexBuddy和PowerGrep是我在windows下常用的两款正则式工具。前者是帮助编写正则式的辅助工具，后者是进行批量搜索替换的实用工具。这两款软件都是外国人写的。今天介绍国人史寿伟先生写的一... ]]></description>
			<content:encoded><![CDATA[<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://www.regexlab.com/images/logo_s.gif" />RegexBuddy和PowerGrep是我在windows下常用的两款正则式工具。前者是帮助编写正则式的辅助工具，后者是进行批量搜索替换的实用工具。这两款软件都是外国人写的。今天介绍国人<a target="_blank" href="http://www.softreg.com.cn/Search.aspx?t=authorid&amp;v=/efff07ff-b552-4034-8860-1964f285c4fc/">史寿伟先生</a>写的一款正则式工具，MTracer 2.0。 </p>
<p><span id="more-32"></span></p>
<p>&#160;</p>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">MTracer 2.0软件版本</h2>
<p>MTracer2.0全名是RegexMatchTracer，官方主页在regexlab.com。上面说最近更新日期是2007.10.07，不过，从我今天下载的程序的修改日期来看，是2008.09.13。变化是，之前作者提供的是绿色的程序，现在提供的是msi的安装包。 本文以下提到MTracer时，若无特殊说明，均指MTracer2.0。</p>
<p>&#160;</p>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">MTracer软件特性</h2>
<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i3.6.cn/cvbnm/61/db/85/73daa684cce5f9fe1d6f327aa5d5502c.jpg" />作为一款正则表达式撰写辅助程序，它拥有查找匹配、替换模式、分割模式，可以分别进行相应操作。前两种用的比较多，各种语言或正则式工具都有相应语句或函数来实现；第三种<strong>分割模式</strong>是指<strong>使用正则表达式来描述字符串的分割符，以便将字串分割成子串数组。</strong>举个简单的例子来说，可以使用正则式<tt class="regex">\d+;?</tt>将<tt class="string">abcd12;sdf55656asdfasd82asd33x</tt>字串分割成子串数组：</p>
<ul>
<li>abcd </li>
<li>sdf </li>
<li>asdfasd </li>
<li>asd </li>
<li>x </li>
</ul>
<p>在实际操作时，你总会遇到使用分割模式才能最有效率地解决的问题。</p>
<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i3.6.cn/cvbnm/df/9f/96/cfd4162eebd15ed35237a49bf94b82ae.jpg" /> 除了一般的选项（忽略大小写、单行\多行、全局），它提供了从右向左、扩展模式两种匹配选项。</p>
<p><strong>从右向左</strong>：平时查找字串最右边的正则式匹配，可以借助于<tt class="regex">?</tt>和<tt class="regex">$</tt>来定位。而在MTracer下，这款比较令人耳目一新的选项十分好玩，虽然我还没有在实际操作时遇到过确需此选项的例子。</p>
<p><strong>扩展模式</strong>：包括如下选项：</p>
<ul>
<li>注释 <tt class="regex">(?#xxx)</tt>：在正则式中加入注释以便提高可读性； </li>
<li>模式修改符 <tt class="regex">(?ismg-ismg)</tt>：小范围内修改匹配模式； </li>
<li>非捕获组 <tt class="regex">(?:xxx)</tt>：匹配而不捕获，便于计数，同时还可以节省内存，提高效率（根据《精通正则表达式》的说法）； </li>
<li>预搜索（零宽度断言）：十分有用的匹配选项，<strong>只匹配位置，而不消耗字符</strong>；有四种模式，详见<a target="_blank" href="http://www.mediafire.com/?ugf3z8tklbl">手册</a>； </li>
<li>独立表达式 <tt class="regex">(?&gt;pattern)</tt>：此选项在《精通正则表达式》中，被余晟先生翻译为&#8220;固化分组&#8221;，即无论匹配成功与否，内部都不进行回退，都不会再次尝试匹配； </li>
<li>条件表达式<tt class="regex">(?(x)y|z)</tt>：与C语言的三目操作符类似，x条件为真则进行y匹配，否则进行z匹配。其中x部分有四种模式，详见<a target="_blank" href="http://www.mediafire.com/?ugf3z8tklbl">手册</a>； </li>
<li>递归表达式 <tt class="regex">(?R)</tt>：对另一部分子表达式的引用，而不是对其匹配结果的引用。当被引用的表达式包含自身，则形成递归引用。 </li>
</ul>
<p>个人比较常用的选项是非捕获组和预搜索。</p>
<p>&#160;</p>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">MTracer最有用的特性</h2>
<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i3.6.cn/cvbnm/1c/a8/f0/2fed4bd2ff41a771aecc1558210c5442.jpg" /> 相对于另一款正则式撰写辅助程序RegexBuddy而言，MTracer最有用的特性是中文的正则式分析树。虽然RegexBuddy也有此功能，但是MTracer的正则式分析树是中文的。这对于需要此功能但是不愿意使用英文软件的用户来说非常方便。对于初学者也很有帮助。</p>
<p>值得说明的是，正则式的中文术语在中文里还没有形成统一的规范。以我自身的阅读经历而言，似可分为两类：何伟平译的《Perl Programming》第三版中大量使用的正则式术语译法为第一套方案，余晟先生译的《精通正则表达式》第三版中使用的正则表达式为第二套。个人倾向于第二套。</p>
<p>MTracer使用的正则表达式术语，与这两套术语均有相异之处。</p>
<p>如果有人使用上述第二套术语将RegexBuddy汉化的话，估计在中国的普及率会大幅提高。题外话。</p>
<p>&#160;</p>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">&#160;</h2>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">与RegexBuddy的简单比较</h2>
<p>还是列表说明吧。</p>
<table border="1" cellspacing="1" cellpadding="2" width="401">
<tbody>
<tr>
<td width="105" align="center"><strong>属性</strong></td>
<td width="132" align="center"><strong>MTracer</strong></td>
<td width="158" align="center"><strong>RegexBuddy</strong></td>
</tr>
<tr>
<td width="103">界面语言</td>
<td width="132">中文</td>
<td width="159">英文</td>
</tr>
<tr>
<td width="102">大小</td>
<td width="132">471kb</td>
<td width="160">9.1 MB</td>
</tr>
<tr>
<td width="103">价格(单用户)</td>
<td width="131">个人RMB49.00<br />
        <br />公司RMB298.00</td>
<td width="160">US$ 39.95</td>
</tr>
<tr>
<td width="103">免费版的限制</td>
<td width="131">正则式长度限制</td>
<td width="160">7天免费使用时间</td>
</tr>
<tr>
<td width="103">帮助文件</td>
<td width="131">原来版本有，最新的msi版已经不带帮助文件；需要的话可以下载本站上传的<a target="_blank" href="http://www.mediafire.com/?ugf3z8tklbl">手册</a>。</td>
<td width="160">齐全。包括4本电子书，其中3本是关于正则表达式的教程、参考手册，1本是RegexBuddy的操作手册。十分翔实。语言是英文。</td>
</tr>
<tr>
<td width="103">匹配模式</td>
<td width="131">
<ol>
<li>匹配 </li>
<li>替换 </li>
<li>分割 </li>
</ol>
</td>
<td width="160">
<ol>
<li>匹配 </li>
<li>替换 </li>
<li>分割 </li>
</ol>
</td>
</tr>
<tr>
<td width="103">匹配选项</td>
<td width="131">
<ol>
<li>忽略大小写（开关） </li>
<li>单行、多行 </li>
<li>全局局部可选 </li>
<li>从右至左 </li>
<li>扩展模式（详见上文） </li>
</ol>
</td>
<td width="160">
<ol>
<li>忽略大小写 （开关） </li>
<li>单行、多行 </li>
<li>默认全局 </li>
<li>点号匹配新行 </li>
<li>^$匹配换行符 </li>
<li>空白字符宽松模式 </li>
<li>扩展模式（依语言而定） </li>
</ol>
</td>
</tr>
<tr>
<td width="103">历史功能</td>
<td width="131">&#8220;文本片断&#8221;即是</td>
<td width="160">History</td>
</tr>
<tr>
<td width="103">导出字串为指定语言</td>
<td width="131">
<ol>
<li>原状导出 </li>
<li>Visual Basic </li>
<li>C/C++ </li>
</ol>
</td>
<td width="160">
<ol>
<li>原状导出 </li>
<li>C/C# </li>
<li>Perl(m//或s///格式) </li>
<li>Basic </li>
<li>Java </li>
<li>JavaScript </li>
<li>Pascal </li>
<li>PHP (//) </li>
<li>PostgreSQL </li>
<li>Python </li>
<li>Ruby </li>
<li>SQL </li>
<li>Tcl </li>
<li>XML </li>
<li><strong>还包含在上述语言中如何调用该正则式的模块，功能强大、有用、好用。（Use）</strong> </li>
</ol>
</td>
</tr>
<tr>
<td width="103">常用正则库</td>
<td width="131">帮助文件中有提及</td>
<td width="160">程序中包含该功能，有定义、例代码、匹配实例。<br />
        <br />帮助文件中也有。</td>
</tr>
<tr>
<td width="103">扩展性</td>
<td width="131">支持插件（疑安装目录下的stdplgin.dll是其插件，功能不详。）</td>
<td width="160">与PowerGrep相关联。</td>
</tr>
<tr>
<td width="103">帮助论坛</td>
<td width="131">开放，地址<a target="_blank" href="http://www.regexlab.com/zh/discuss/forum.aspx?b=1">在此</a></td>
<td width="160">仅对付费注册软件的用户开放。</td>
</tr>
<tr>
<td width="103">界面高度可定制</td>
<td width="132">不支持</td>
<td width="161">支持</td>
</tr>
<tr>
<td width="103">是否支持批量替换外部文件</td>
<td width="132">不支持</td>
<td width="161">支持</td>
</tr>
</tbody>
</table>
<p>当然，没有提到的功能、细节还不少，这里仅仅是列出本人关注的属性。</p>
<p>&#160;</p>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">MTracer 2.0注册</h2>
<p>付出劳动，换来报酬，是当今任何行业都认可的规则。MTracer需要注册费，这一点也十分正常。其价格是48元人民币。比起US$ 39.95的RegexBuddy来，可谓性价比极高。</p>
<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i3.6.cn/cvbnm/a7/08/a1/f3e2daa8f96c1c47d4b08ef7a6c14224.jpg" /> </p>
<p>如果不注册，会有什么限制呢？请看图。哦，是有100个字符的限制。</p>
<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i3.6.cn/cvbnm/4c/d6/e2/5dcb18e7a4610987954ee363624a3584.jpg" /> 这是注册后的图。</p>
<p>对于未注册版本，平时写一些短小的正则式，是没有问题的。如果想无限制地使用该程序，花48元支持一下国产程序，何乐而不为？</p>
<p>现在无论主动还是被动，版权意识都在深入人心。这也是本人一直没有把完全版的RegexBuddy和PowerGrep的下载链接贴到blog上、而是采取来Email索取的原因之一。</p>
<p><img style="border-bottom: rgb(255,255,255) 1px solid; border-left: rgb(255,255,255) 1px solid; margin: 0px 10px 10px; padding-left: 0px; float: right; clear: both; border-top: rgb(255,255,255) 1px solid; border-right: rgb(255,255,255) 1px solid" src="http://i3.6.cn/cvbnm/06/e9/0d/fe543fab025def9627a7f1a4df30f354.jpg" /> MTracer2.0采用注册号的方式注册。看来作者深知在国内破解成风，于是很幽默地添加了这样一则菜单选项：如何8小时破解本软件？呵呵。8小时我们可以做许多事情，没有必要浪费在track、debug、crack上。你的时间很值钱的。</p>
<p>这两款软件的完全版我这里都有，如果需要RegexBuddy的话，请占击链接留下信箱索取即可；但是MTracer的话就<strong>不要</strong>索取了。</p>
<p>&#160;</p>
<h2 style="background-color:#99CC00; font-size:14px; padding-bottom:3px; padding-left:10px; padding-top:3px;  line-height:1.5em; margin:1.5em 0 1em;">相关阅读</h2>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;"><a href="http://iregex.org/blog/regexbuddy.html">windows下的正则式工具介绍之一：RegexBuddy</a></h4>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;"><a href="http://iregex.org/blog/powergrep.html">windows下的正则式工具介绍之二：powergrep</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/mtracer-vs-regexbuddy.html/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>如狐添翼：FireFox3正则表达式搜索插件/Find Bar/</title>
		<link>http://iregex.org/blog/find-bar-for-firefox-and-thunderbird-as-regular-expression-searching-engine.html</link>
		<comments>http://iregex.org/blog/find-bar-for-firefox-and-thunderbird-as-regular-expression-searching-engine.html#comments</comments>
		<pubDate>Mon, 28 Jul 2008 02:18:57 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=20</guid>
		<description><![CDATA[原来在FireFox2.x中使用过一个插件FindBar，十分好用。升级到firefox3.0之后，FB居然冬眠。今天终于看到更新，能继续在firefox中使用了，心情超爽，特写日志以记之。 意译一下作者的介绍。插件主... ]]></description>
			<content:encoded><![CDATA[<p>原来在FireFox2.x中使用过一个插件FindBar，十分好用。升级到firefox3.0之后，FB居然冬眠。今天终于看到更新，能继续在firefox中使用了，心情超爽，特写日志以记之。<a href="https://1n5vfq.bay.livefilestore.com/y1p9yjXzii5NFmllV2lT0g4PYDrg90_Z4F1mRJBxymy-0BQ4AB-Maiua3F9ktYIVYLWP4yd_EqbB_mMUAq_6zKc7g/%E5%8F%A4%E5%BA%99%E5%87%84%E9%A3%8E.mp3"></a><br />
<span id="more-20"></span><br />
意译一下作者的介绍。插件主页、介绍原文在<a href="http://www.oxymoronical.com/web/firefox/FindBarRX" target="_blank">这里</a>。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<a href="http://iregex.org" target="_blank">正则表达式</a>分割线&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;">/Find Bar/</h3>
<p>/Find Bar/ is a new extension for Firefox that is still a little bit in progress. I&#8217;ve always believed that one of the best features of Firefox is it&#8217;s quick find bar. I probably use it about 20 times a day, if not more. But it has to be said its a fairly simple beast. When it comes to more powerful searches you&#8217;re just out of luck. This extension adds a whole new dimension to the find bar, regular expressions. The regular expressions are implemented using the JavaScript engine so check the JavaScript RegExp syntax for the full details.</p>
<p>/Find Bar/是FireFox的新插件，目前仍在完善中。对于firefox，我一直觉得它方便快捷的搜索栏是其亮点之一。我每天使用该功能20次以上。但是必须承认，其搜索功能太过薄弱。当你要搜索更复杂的内容时，它就无能为力了。</p>
<p>本插件为搜索栏添加了新选项：<a href="http://iregex.org" target="_blank">正则表达式</a>。它使用了JavaScript正则式引擎。请查询<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions" target="_blank">JavaScript RegExp文档</a>来了解语法细节内容。</p>
<p>有待解决的两个问题：</p>
<ul>
<li> Whitespace. HTML is made up a lot of this, most of it is ignored by the browser and not visible on the page. At the moment this extension doesn’t ignore anything so you may find there are more spaces between words than you expected. Should I err on the side of accuracy as it is now, or collapse all whitespace?空白符（水平制表符、空格等）。HTML中包含了许多空白符，其中一大部分被浏览器忽略掉，不在页面上显示出来。目前该插件没有忽略任何字符，因此你会发现，单词之间往往有更多的空白符符。我是该精确地显示出每个空白字符呢，还是该将其全部压缩？</li>
<li> Block content. The standard find bar wont find searches that span blocks (paragraphs in human terms). This extension does, which while potentially useful also causes some issues. One thought is to make each paragraph like a line then you can use line breaks to match paragraphs as you might expect.区块内容。标准的搜索栏不会跨区块（亦即段落）搜索，而本插件搜索时却会跨越区块，这既是便利之处，但是也有可能带来副作用。一种思路是将每一段落处理为一个文本行，这样您就可以使用换行符来匹配段落。</li>
</ul>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;">该插件的兼容性</h3>
<p style="text-align: center; font-weight: bold; font-size: 107%;">
<table border="1" cellspacing="1" cellpadding="2" width="281">
<tbody>
<tr>
<td width="101" valign="top">FireFox</td>
<td width="52" valign="top"><img style="vertical-align: middle;" title="Firefox" src="http://www.oxymoronical.com/shared/images/firefox.png" alt="Firefox" /></td>
<td width="122" valign="top">2.0b1 &#8211; 3.1a2pre</td>
</tr>
<tr>
<td width="103" valign="top">ThunderBird</td>
<td width="54" valign="top"><img style="vertical-align: middle;" title="Thunderbird" src="http://www.oxymoronical.com/shared/images/thunderbird.png" alt="Thunderbird" /></td>
<td width="122" valign="top">2.0 &#8211; 3.0a1</td>
</tr>
</tbody>
</table>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;">下载地址</h3>
<p style="text-align: center; font-weight: bold; font-size: 107%;"><a href="https://addons.mozilla.org/downloads/file/34434/_find_bar_-1.0.1-fx+tb.xpi"><img style="vertical-align: middle;" src="https://addons.mozilla.org/img/addon-icn.png" alt="/Find Bar/" /></a> <a href="https://addons.mozilla.org/downloads/file/34434/_find_bar_-1.0.1-fx+tb.xpi">Install v1.0.1</a></p>
<p style="text-align: center; font-size: 84%;">(Installs from <a href="https://addons.mozilla.org/addon/6534">addons.mozilla.org</a>)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<a href="http://iregex.org" target="_blank">正则表达式</a>分割线&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>跨区块搜索我觉得不是大问题，对于空白字符，我的解决方法是，只要是使用<a href="http://iregex.org" target="_blank">正则表达式</a>来搜索，就在使用空格时使用\s+来表示。这样，从内容上，它表示了任何种类的空白字符；从数量上，它表示了最少一个（多则不限）的空白字符，既不错杀，也无冤死。</p>
<p>由此引发的感慨是：人的眼睛所能看到的字符是有限的，其所看到内容与事实的真相有时未必相符。而程序是精确的，每一个比特都明察秋毫。（例如在汇编语言中的数字0与ASCII字符&#8217;0&#8242;就截然不同。虽然在perl中，两者单独出现时被视为是同一事物。）</p>
<p>该插件还能结合原搜索栏的全部高亮显示选项来显示，便于显示所有的匹配。在搜索英文等外语时，你会发现这一点十分有用。</p>
<p>另外有一点得陇望蜀的心思是，如果该插件支持保存常用搜索就好了。比方搜索email地址的、URL的，日期的，诸如此类。虽如此，这款插件已经十分好用，强烈推荐。</p>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/find-bar-for-firefox-and-thunderbird-as-regular-expression-searching-engine.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>windows下的正则式工具介绍之二：powergrep</title>
		<link>http://iregex.org/blog/powergrep.html</link>
		<comments>http://iregex.org/blog/powergrep.html#comments</comments>
		<pubDate>Mon, 05 May 2008 08:18:09 +0000</pubDate>
		<dc:creator>rex</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[powergrep]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regexbuddy]]></category>
		<category><![CDATA[正则式]]></category>
		<category><![CDATA[正则表达式]]></category>

		<guid isPermaLink="false">http://iregex.org/?p=7</guid>
		<description><![CDATA[上文介绍了RegexBuddy，本文介绍另一款windows下的正则式软件：PowerGREP，号称“The Most Powerful GREP Tool for Windows”，windows下最强大的GREP工具。看清楚了，是最强大，而非之一。与RegexBuddy一样，也是... ]]></description>
			<content:encoded><![CDATA[<p>上文介绍了RegexBuddy，本文介绍另一款windows下的正则式软件：PowerGREP，号称“The Most Powerful GREP Tool for Windows”，windows下最强大的GREP工具。看清楚了，是<font color="#ff0084">最强大</font>，而非<font color="#ff0084">之一</font>。与RegexBuddy一样，也是商业软件，其售价为US$149.00，合人民币1000有奇。如果说RegexBuddy是撰写正则式的贴心助手，那么PowerGREP则是应用正则式在文本文件中搜索替换的强大工具。现在我们看看，它究竟有什么功能敢号称<b>最强</b>。</p>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;">基本界面</h3>
<p><a target="_blank" href="http://www.powergrep.com/screens/powergrep800.png"><img style="max-width: 800px;" src="http://www.powergrep.com/screens/powergrep320.png" /></a></p>
<p>点击可以看大图。另外，还有一组图片来自<a target="_blank" href="http://www.powergrep.com">powergrep</a>官网，附上了官网的部分介绍，以及个人评论。</p>
<ul>
<li>内容搜索图片，点<a target="_blank" href="http://www.powergrep.com/screens/powergrep800.png">这里</a>；<br />
在本抓图中，我搜索了<font color="#ff0084">c:\My Documents\My Web Sites</font>文件夹及其子目录下所有的html文件。我使用了一条正则表达式把搜索范围限定在HTML tag之内，使用另一条正则式在这些<span class="hl">标记中搜索所有的email地址。</p>
<p></span></li>
<li>搜索和替换，点<a target="_blank" href="http://www.powergrep.com/screens/replacepreview.png">这里</a>和<a target="_blank" href="http://www.powergrep.com/screens/replace.png">这里</a>；<br />
一个好用的功能是可以<font color="#ff0084">预览</font>结果而不是立即替换。匹配结果以黄色标出。双击匹配就能打开对应的文档并检验其内容。<br />
点击<font color="#ff0084">执行</font>后，颜色改变，表示已经实施替换。</p>
</li>
<li>收集信息和统计数据，点<a target="_blank" href="http://www.powergrep.com/screens/collect.png">这里</a>；<br />
本例是“检测Apache网络日志－－google search terms”的例子。本例使用的正则式在PowerGREP帮助文档中有详细讲解。</p>
</li>
<li>灵活的“撤消”历史记录，让你不再抓狂，点<a href="http://www.powergrep.com/screens/undo.png" target="_blank">这里</a>；<br />
在执行替换的同时，PowerGREP已经备份了原文件。只要你没有手动删除这些备份的文件，你可以随便撤消你做过的任何操作。世界上真有后悔药的呀。</p>
</li>
<li>搜索PDF文档，点<a target="_blank" href="http://www.powergrep.com/screens/pdf.png">这里</a>；<br />
PDF也能使用正则式进行搜索？当然了，你没有看错。只是，要确保PDF文档中你要搜索的内容是<font color="#ff0084">文字</font>而非<font color="#ff0084">图像</font>。也就是说，扫描版的PDF不享受此功能的哟。</p>
</li>
<li>在MS word 文档中搜索，点<a target="_blank" href="http://www.powergrep.com/screens/msword.png">这里</a>；<br />
这个功能也十分有用。我记得还有个东东叫<a target="_blank" href="http://www.viemu.com/">ViEmu for Word &amp; Outlook</a>，可以在word和outlook中模拟vim，当然可以使用正则式搜索替换了。不过，ViEmu一来也是收费软件（在2008年5月31日之前是79美刀，之后是99美刀），我还没有找到免费版本；二来其正则式是vim风格的，只习惯Perl风格的同学可能不太习惯。在google documents里也支持正则式搜索了，具体语法、风格尚未广泛测试。</p>
</li>
<li>在MS Excel中搜索，点<a target="_blank" href="http://www.powergrep.com/screens/excel.png">这里</a>；<br />
同样也是批量搜索、替换。不单单是对一个文档、一个sheet。</p>
</li>
<li>以16进制模式，在2进制文档中搜索，点<a target="_blank" href="http://www.powergrep.com/screens/binaryfiles.png">这里</a>；<br />
跟二进制编辑器界面类似，多了正则式批量搜索替换功能。</p>
</li>
<li>在zip压缩文档中搜索，点<a target="_blank" href="http://www.powergrep.com/screens/zip.png">这里</a>；<br />
把zip文件当作普通文件夹来搜索。很强大吧？</p>
</li>
<li>正则表达式序列，点<a target="_blank" href="http://www.powergrep.com/screens/sequence.png">这里</a>；<br />
大多数正则式工具一次只支持一条正则式的操作。而PowerGREP可以一次执行多条正则式！使用checkbox来进行多项选择。</p>
</li>
<li>定制颜色显示，点<a target="_blank" href="http://www.powergrep.com/screens/colors.png">这里</a>；<br />
该功能比较一般。除非软件中的颜色设置特傻，一般我是不会改变默认颜色搭配的。
</li>
</ul>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;">功能演示</h3>
<p>PowerGREP官网还提供了一组flash做的demo，见下。</p>
<ul>
<li>使用正则式匹配email地址(2&#8217;47&#8221;)。点<a target="_blank" href="http://www.powergrep.com/demos/email.swf">这里</a>；</li>
<li>升级版权信息(3&#8217;38)。点<a target="_blank" href="http://www.powergrep.com/demos/copyright.swf">这里</a>；</li>
<li>与RegexBuddy的无缝链接(1&#8217;57&#8221;)，点这里；两个软件是亲兄弟，当然哥俩好啦！
</li>
<li>文件选择(3&#8217;08&#8221;)，点<a target="_blank" href="http://www.powergrep.com/demos/filesel.swf">这里</a>；PowerGREP提供了贴心的特性，来帮助你筛选需要的文档。</li>
<li>其它特性(8&#8217;37&#8221;)，点<a target="_blank" href="http://www.powergrep.com/demos/action.swf">这里</a>；总而言之，PowerGREP是功能强大。自己发掘吧！</li>
</ul>
<h3 style="color: #127ADB; font-size:14px; padding-bottom:3px; padding-top:3px; margin:1.5em 0 1em;">软件下载</h3>
<p> 目前其最新版为3.4.2，更新于2008年1月18日。其官网为<a href="http://www.powergrep.com/" target="_blank">www.powergrep.com</a>，可以去下载其最新版试用。<strong>该软件为商业软件</strong>。
<ul>
<li>如果你偶然路过，尝新而已，那只需<a href="http://www.powergrep.com/download.html" target="_blank">下载试用版</a>即可；</li>
<li>如果你觉得好用、准备常用、手有余钱、非正版不用，不妨<a http:="" www.powergrep.com="" buynow.html="">花美金购买</a>；要花人民币1000多块哟^_^</li>
<li><del datetime="2009-01-08T01:51:13+00:00">如果你喜欢它，同时你认为优秀的网络资源是应该和朋友免费分享的，从而想获得该软件的全功能免费版，好吧，我也成全你，请在本文后留言（附邮箱），我会把这个小东西的链接发给你(最新版为3.4.2，我手头的全功能版为3.3.3，也足够用了)。</del><strong>更新：</strong><br />
请移步至此下载<a href="http://iregex.org/blog/powergrep350.html">PowerGREP 3.5.0</a>版。</li>
</ul>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
]]></content:encoded>
			<wfw:commentRss>http://iregex.org/blog/powergrep.html/feed</wfw:commentRss>
		<slash:comments>114</slash:comments>
		</item>
	</channel>
</rss>
