<?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>mdgArt &#187; regexp</title>
	<atom:link href="http://www.mdgart.com/tag/regexp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mdgart.com</link>
	<description>Art &#38; Programming</description>
	<lastBuildDate>Thu, 12 Jan 2012 11:56:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RegEx: Link not beginning with http://</title>
		<link>http://www.mdgart.com/2009/01/23/regex-link-not-beginning-with-http/</link>
		<comments>http://www.mdgart.com/2009/01/23/regex-link-not-beginning-with-http/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 16:54:01 +0000</pubDate>
		<dc:creator>Mauro</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[pcre]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.mdgart.com/?p=3</guid>
		<description><![CDATA[I had to find a regex to match not a string that contain something, but a string that not contain something, and in particular i had to check that a link entered in a form does not begin with http://. I needed to use a regex for this that work with PHP and, i have to admin, it was not so simple. ]]></description>
			<content:encoded><![CDATA[<p>I had to find a regex to match not a string that contain something, but a string that not contain something, and in particular i had to check that a link entered in a form does not begin with http://. I needed to use a regex for this that work with PHP and, i have to admin, it was not so simple.<br />
The method that i found is based on lookahead technique, but seem to work only with preg_match() and not with ereg(). Is not perfect, because it don&#8217;t match any string that contain http://, not only that begin with.<br />
This is the regex:</p>
<p><code><br />
(^((?!.*http\://).)*$)<br />
</code></p>
<p>This match www.ciao.com, but not http://www.ciao.com and also not www.ciao.com/http:// and any string that contain http://. It work for my needs, but is not what really wanted to achieve.<br />
If you know a method to correct the regex, please tell me.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="mauro@ondadiluce.com" /><input type="hidden" name="return" value="" /><input type="hidden" name="item_name" value="Buy me a coffe for RegEx: Link not beginning with http://" /><input type="hidden" name="currency_code" value="EUR" /><input type="hidden" name="amount" value="1" /><input type="image" src="http://www.mdgart.com/wp-content/plugins/buy-me-beer/icon_cafe.gif" align="left" alt="Buy me a coffe" title="Buy me a coffe" hspace="3" style="border:0;" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=mauro@ondadiluce.com&amp;currency_code=EUR&amp;amount=1&amp;return=&amp;item_name=Buy+me+a+coffe+for+RegEx:+Link+not+beginning+with+http://" target="paypal">Donate 1 euro, buy me a coffee, I need it to write more posts! Thanks ;)</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mdgart.com/2009/01/23/regex-link-not-beginning-with-http/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

