<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Not Substring Regular Expressions</title>
	<atom:link href="http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/</link>
	<description>Ranting and Raving</description>
	<pubDate>Tue, 02 Dec 2008 20:22:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Neil Greenwood</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-47340</link>
		<dc:creator>Neil Greenwood</dc:creator>
		<pubDate>Fri, 23 Feb 2007 08:59:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-47340</guid>
		<description>I think Minute Bol's second suggestion above uses Java RegEx's negative look-behind assertion. My copy of "Java in a Nutshell (4th ed)" says that the pattern "must be a...fixed number of characters", so I don't think his suggestion will work exactly. There's no such restriction on the negative look-ahead assertion, but I can't think how to re-write the regex that way.

HTH. Hwyl,
Neil.</description>
		<content:encoded><![CDATA[<p>I think Minute Bol&#8217;s second suggestion above uses Java RegEx&#8217;s negative look-behind assertion. My copy of &#8220;Java in a Nutshell (4th ed)&#8221; says that the pattern &#8220;must be a&#8230;fixed number of characters&#8221;, so I don&#8217;t think his suggestion will work exactly. There&#8217;s no such restriction on the negative look-ahead assertion, but I can&#8217;t think how to re-write the regex that way.</p>
<p>HTH. Hwyl,<br />
Neil.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-46040</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 20 Feb 2007 09:19:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-46040</guid>
		<description>Something like this should be ok

(lets see if a pre tag can help me)


while( $html =~/
                        (
                        ]*         #0 or more non &#62;
                                        \s+alt\s*=   #and an alt attribute
                                )
                        [^&#62;]*                          #instead followed by 0 or more non &#62;
                        &#62;                                #and a tag close
                        )/xg)
{
        print $1."\n\n";
}
</description>
		<content:encoded><![CDATA[<p>Something like this should be ok</p>
<p>(lets see if a pre tag can help me)</p>
<p>while( $html =~/<br />
                        (<br />
                        ]*         #0 or more non &gt;<br />
                                        \s+alt\s*=   #and an alt attribute<br />
                                )<br />
                        [^&gt;]*                          #instead followed by 0 or more non &gt;<br />
                        &gt;                                #and a tag close<br />
                        )/xg)<br />
{<br />
        print $1.&#8221;\n\n&#8221;;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-46038</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 20 Feb 2007 09:18:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-46038</guid>
		<description>Something like this should be ok

while( $html =~/
                        (
                        ]*         #0 or more non &#62;
                                        \s+alt\s*=   #and an alt attribute
                                )
                        [^&#62;]*                          #instead followed by 0 or more non &#62;
                        &#62;                                #and a tag close
                        )/xg)
{
        print $1."\n\n";
}</description>
		<content:encoded><![CDATA[<p>Something like this should be ok</p>
<p>while( $html =~/<br />
                        (<br />
                        ]*         #0 or more non &gt;<br />
                                        \s+alt\s*=   #and an alt attribute<br />
                                )<br />
                        [^&gt;]*                          #instead followed by 0 or more non &gt;<br />
                        &gt;                                #and a tag close<br />
                        )/xg)<br />
{<br />
        print $1.&#8221;\n\n&#8221;;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed Davies</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-45837</link>
		<dc:creator>Ed Davies</dc:creator>
		<pubDate>Tue, 20 Feb 2007 00:21:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-45837</guid>
		<description>&lt;i&gt;What am I missing?&lt;/i&gt;  XPath?

Sorry, couldn't help it.</description>
		<content:encoded><![CDATA[<p><i>What am I missing?</i>  XPath?</p>
<p>Sorry, couldn&#8217;t help it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Minute Bol</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-45726</link>
		<dc:creator>Minute Bol</dc:creator>
		<pubDate>Mon, 19 Feb 2007 18:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-45726</guid>
		<description>hey rusty - no 'preview' button?  let's try that again:
(?!&#60;img[^&#62;]*\salt[^=&#62;]*=[^&#62;]*&#62;)&#60;img[^&#62;]*&#62;
matches the thing and then makes sure there was no ' alt=' in the match, or something to that effect</description>
		<content:encoded><![CDATA[<p>hey rusty - no &#8216;preview&#8217; button?  let&#8217;s try that again:<br />
(?!&lt;img[^&gt;]*\salt[^=&gt;]*=[^&gt;]*&gt;)&lt;img[^&gt;]*&gt;<br />
matches the thing and then makes sure there was no &#8216; alt=&#8217; in the match, or something to that effect</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Minute Bol</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-45725</link>
		<dc:creator>Minute Bol</dc:creator>
		<pubDate>Mon, 19 Feb 2007 18:46:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-45725</guid>
		<description>yeah that's a good one.  here's what i came up with:
(?!]*\salt[^&#62;]*&#62;$)]*&#62;
seems to work.</description>
		<content:encoded><![CDATA[<p>yeah that&#8217;s a good one.  here&#8217;s what i came up with:<br />
(?!]*\salt[^&gt;]*&gt;$)]*&gt;<br />
seems to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xan Gregg</title>
		<link>http://www.elharo.com/blog/software-development/perl/2007/02/19/not-substring-regular-expressions/#comment-45723</link>
		<dc:creator>Xan Gregg</dc:creator>
		<pubDate>Mon, 19 Feb 2007 18:29:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/02/19/not-substring-regular-expressions/#comment-45723</guid>
		<description>This works pretty well for me (in BBEdit), ignoring case:

&#60;img([^&#62;a]&#124;a[^l]&#124;al[^t]&#124;".*"&#124;'.*')*?&#62;

It allows
any character not a '&#62;' or 'a'
any 'a' not followed by an 'l'
any 'al' not followed by an 't'
anything in quotes


So it disallows 'alt' outside of quotes. Will give a false results for any other tags containing 'alt'.

You might also want to search for: alt="".</description>
		<content:encoded><![CDATA[<p>This works pretty well for me (in BBEdit), ignoring case:</p>
<p>&lt;img([^&gt;a]|a[^l]|al[^t]|&#8221;.*&#8221;|&#8217;.*&#8217;)*?&gt;</p>
<p>It allows<br />
any character not a &#8216;&gt;&#8217; or &#8216;a&#8217;<br />
any &#8216;a&#8217; not followed by an &#8216;l&#8217;<br />
any &#8216;al&#8217; not followed by an &#8216;t&#8217;<br />
anything in quotes</p>
<p>So it disallows &#8216;alt&#8217; outside of quotes. Will give a false results for any other tags containing &#8216;alt&#8217;.</p>
<p>You might also want to search for: alt=&#8221;".</p>
]]></content:encoded>
	</item>
</channel>
</rss>
