<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: greedy code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 06:00:28 GMT</pubDate>
    <description>DZone Snippets: greedy code</description>
    <item>
      <title>Greedy vs Lazy in Regular Expressions</title>
      <link>http://snippets.dzone.com/posts/show/5103</link>
      <description>The greedy expression can be seen as a True *and* False predicate, meaning true while the token is valid, while being false if the pattern matching hasn't been exhausted. &lt;br /&gt;The lazy expression is the True *or* False predicate, meaning true while the token is valid, or false if the pattern match hasn't been fully exhausted.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;irb(main):037:0&gt; "&lt;EM&gt;first&lt;/EM&gt;"[/&lt;.+&gt;/] #greedy &lt;br /&gt;=&gt; "&lt;EM&gt;first&lt;/EM&gt;"&lt;br /&gt;irb(main):038:0&gt; "&lt;EM&gt;first&lt;/EM&gt;"[/&lt;.+?&gt;/] #lazy&lt;br /&gt;=&gt; "&lt;EM&gt;"&lt;br /&gt;irb(main):039:0&gt; "&lt;EM&gt;first&lt;/EM&gt;"[/&lt;[^&lt;&gt;]+&gt;/] # better solution&lt;br /&gt;=&gt; "&lt;EM&gt;"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;source: &lt;a href="http://www.regular-expressions.info/quickstart.html"&gt;Regular Expression Quick Start&lt;/a&gt; [regular-expressions.info]</description>
      <pubDate>Mon, 04 Feb 2008 13:09:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5103</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
  </channel>
</rss>
