<?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://blog.chacuo.net/category/tools/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.chacuo.net</link>
	<description>web原理、web架构、web安全、web性能、服务器性能、服务器架构、服务器安全;你不能预知明天，但你可以利用今天。你不能样样顺利，但你可以事事尽力!</description>
	<lastBuildDate>Mon, 31 Aug 2020 15:33:40 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>正则表达式性能测试工具推荐、优化工具推荐(regexbuddy推荐)</title>
		<link>http://blog.chacuo.net/238.html</link>
		<comments>http://blog.chacuo.net/238.html#comments</comments>
		<pubDate>Thu, 13 Jun 2013 14:59:17 +0000</pubDate>
		<dc:creator>程默</dc:creator>
				<category><![CDATA[web性能]]></category>
		<category><![CDATA[学习工具]]></category>
		<category><![CDATA[正则表达式]]></category>

		<guid isPermaLink="false">http://blog.chacuo.net/?p=238</guid>
		<description><![CDATA[前不久，我们推荐了个正则表达式入门学习工具。正则表达式工具推荐（学习工具、测试工具） ，今天我们看下，正则表达 [...]]]></description>
				<content:encoded><![CDATA[<p>前不久，我们推荐了个正则表达式入门学习工具。<a href="http://blog.chacuo.net/198.html">正则表达式工具推荐（学习工具、测试工具）</a> ，今天我们看下，正则表达式的性能测试工具。这里我们先说下，为什么需要这样的工具，这个工具有什么作用呢？</p>
<ul>
<li>
<h3><span style="font-weight: bold">为什么需要性能测试工具</span></h3>
</li>
</ul>
<h3></h3>
<p>我们都知道，正则表达式使用进行搜索查找，没有字符串直接查找快！而且性能是几何倍数下降。那么，为什么正则表达式速度会比字符串搜索慢呢。我们来看看，正则表达式查找字符串的匹配过程吧。正则表达式由一些元字符，普通字符，量词字符组合成。默认情况下，这些量词元字符（*,+,?)都是贪婪模式，会最大长度匹配字符串。我们知道，正则表达式往往搜索路径会有多个，我们看看，下面匹配过程。就知道，主要影响正则表达式执行性能有哪些了。</p>
<p>正则表达式匹配过程如：\d+abc，元字符是：”12345bdc”，查找会从左向右进行，\d+，贪婪模式，一下子匹配到12345，然后bdc与\d+不能匹配，”abc”中,”a”字符，开始匹配”bdc”，发现匹配失败。正则表达式开始回溯匹配（贪婪模式量词开始逐一减少匹配字符长度)，\d+只匹配”1234”，”5bdc”与”abc”匹配，任然失败。\d+继续减少匹配长度为：”123”，”45bdc”与”abc”匹配，任然失败。继续回退，直到\d+匹配”1”，用”2345bdc”与”bdc”匹配，任然失败。整个匹配就失败了。</p>
<p>从上面过程中，我们发现，每次回溯，要重新操作匹配因此匹配搜索次数，直接影响正则表达式的性能。做正则表达式性能优化，一般就是优化查询的次数。这个是我们分析过程，如果有个工具能够实实在在看到每一步匹配过程，对于我们优化正则表达式将带来太多方便了。这里介绍工具是：<strong>regexbuddy软件</strong>，它就是一个实实在在看到匹配过程工具。</p>
<ul>
<li>
<h3><span style="font-weight: bold">regexbuddy工具怎么样使用，使用介绍</span></h3>
</li>
</ul>
<blockquote><pre>1、安装完<strong>regexbuddy</strong></pre>
<p></p>
<pre><strong></strong></pre>
<p></p>
<pre><a href="http://blog.chacuo.net/wp-content/uploads/2013/06/image23.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="regexbuddy介绍" border="0" alt="regexbuddy介绍" src="http://blog.chacuo.net/wp-content/uploads/2013/06/image_thumb23.png" width="863" height="523"></a></pre>
<p>该工具支持多种程序语言正则表达式，如：perl,pcre,javascript,python,ruby,c#,java等等，还能自动生成程序代码，并且内部带有大量的常用正则表达式。</p>
<pre>2、一般切换到side by side：</pre>
<p></p>
<pre></pre>
<p></p>
<pre><a href="http://blog.chacuo.net/wp-content/uploads/2013/06/image24.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="regexbuddy使用" border="0" alt="regexbuddy使用" src="http://blog.chacuo.net/wp-content/uploads/2013/06/image_thumb24.png" width="865" height="549"></a></pre>
<p></p>
<pre></pre>
<p></p>
<pre>3、匹配过程</pre>
<p></p>
<pre></pre>
<p></p>
<pre><a href="http://blog.chacuo.net/wp-content/uploads/2013/06/image25.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="regexbuddy匹配过程" border="0" alt="regexbuddy匹配过程" src="http://blog.chacuo.net/wp-content/uploads/2013/06/image_thumb25.png" width="867" height="524"></a></pre>
<p></p>
<pre></pre>
<p></p>
<pre><a href="http://blog.chacuo.net/wp-content/uploads/2013/06/image26.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="regexbuddy匹配过程" border="0" alt="regexbuddy匹配过程" src="http://blog.chacuo.net/wp-content/uploads/2013/06/image_thumb26.png" width="866" height="524"></a></pre>
<p>从上面一个匹配看，这个简单一个匹配，搜索了8次，进行了不断查找。如果我们已经准确知道自己要匹配什么样字符，我们可以对源正则表达式修改下，减少匹配次数。就达到优化正则表达式目的，提高匹配效率！</p>
<pre><a href="http://blog.chacuo.net/wp-content/uploads/2013/06/image27.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="regexbuddy优化正则表达式" border="0" alt="regexbuddy优化正则表达式" src="http://blog.chacuo.net/wp-content/uploads/2013/06/image_thumb27.png" width="869" height="526"></a></pre>
<p></p>
<pre></pre>
<p></p>
<pre></pre>
<p></p>
<pre></pre>
<p></p>
<pre></pre>
</blockquote>
<p><strong>后记：</strong>这个工具是不是很强大呢，你知道在baidu搜索，该关键字：<strong>regexbuddy，</strong>就可以方便下载到。通过该工具，对我们写出好的高性能正则表达式确实能带来很大帮助。有时候可能一个小小修改，自己程序正则表达式匹配速度可能几个数量级的提升。好了，欢迎大家交流，你有好的工具、方法，欢迎留言，可以给更多朋友分享！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chacuo.net/238.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>正则表达式工具推荐（学习工具、测试工具）</title>
		<link>http://blog.chacuo.net/198.html</link>
		<comments>http://blog.chacuo.net/198.html#comments</comments>
		<pubDate>Mon, 10 Jun 2013 15:25:41 +0000</pubDate>
		<dc:creator>程默</dc:creator>
				<category><![CDATA[学习工具]]></category>
		<category><![CDATA[正则表达式]]></category>

		<guid isPermaLink="false">http://blog.chacuo.net/?p=198</guid>
		<description><![CDATA[我们学习正则表达式，有个好的工具，对于我们初学者还是不错的选择。这里推荐大家使用：RegExBuilder工具 [...]]]></description>
				<content:encoded><![CDATA[<p>我们学习正则表达式，有个好的工具，对于我们初学者还是不错的选择。这里推荐大家使用：RegExBuilder工具，该工具支持正则表达式多种扩展类型匹配方式，包括：单行，多行，从右向左，忽略大小写等。匹配结果直观显示。截图如下：</p>
<p>&nbsp;</p>
<blockquote><p><a href="http://blog.chacuo.net/wp-content/uploads/2013/06/image13.png"><img style="background-image: none; margin: 0px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" alt="image" src="http://blog.chacuo.net/wp-content/uploads/2013/06/image_thumb13.png" width="830" height="490" border="0" /></a></p></blockquote>
<p>将原始字符串输入，就可以在正则表达式窗口写入表达式，一边写一边有提示字符。如果有出错，还有错误提示。下面就会显示匹配到的结果。非常方便！该工具，可以搜索：<a title="搜索：RegExbuider" href="http://www.baidu.com/s?ie=utf-8&amp;bs=regexbuilder&amp;f=8&amp;rsv_bp=1&amp;rsv_spt=3&amp;wd=regexbuilder&amp;inputT=0" target="_blank">regExbuilder</a> ，有好的工具，欢迎交流！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chacuo.net/198.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
