<?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>Notes of a Developer &#187; RegExp</title>
	<atom:link href="http://www.developers-life.com/tag/regexp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developers-life.com</link>
	<description>Develop on Objective-C, UIKit, C, OpenGL for  iPhone, iPad, Mac OS X</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:49:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>NSRegularExpression sample for comment syntax highlighting</title>
		<link>http://www.developers-life.com/nsregularexpression-sample-for-comment-syntax-highlighting.html</link>
		<comments>http://www.developers-life.com/nsregularexpression-sample-for-comment-syntax-highlighting.html#comments</comments>
		<pubDate>Tue, 08 Nov 2011 00:25:10 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[matchesInString]]></category>
		<category><![CDATA[NSRegularExpression]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[regexpal]]></category>
		<category><![CDATA[regularExpressionWithPattern]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1321</guid>
		<description><![CDATA[I have this text: 1word1 word2 &#34; word3 //&#34; word4 I wrote simple solution. I know it can be better. I know about Back Reference, but i don&#8217;t have experience with it. 123456789101112131415161718192021222324252627282930313233NSRegularExpression *expression = &#91;NSRegularExpression regularExpressionWithPattern:@&#34;((@\&#34;&#124;\&#34;).*?(\&#34;))&#34; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I have this text:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">word1 word2 <span style="color: #bf1d1a;">&quot; word3 //&quot;</span> word4</div></td></tr></tbody></table></div>
<p>I wrote simple solution. I know it can be better. I know about Back Reference, but i don&#8217;t have experience with it.</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NSRegularExpression <span style="color: #002200;">*</span>expression <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSRegularExpression regularExpressionWithPattern<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;((@<span style="color: #2400d9;">\&quot;</span>|<span style="color: #2400d9;">\&quot;</span>).*?(<span style="color: #2400d9;">\&quot;</span>))&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options<span style="color: #002200;">:</span>NSRegularExpressionDotMatchesLineSeparators <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>textArray <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>expression matchesInString<span style="color: #002200;">:</span>textString options<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span> range<span style="color: #002200;">:</span>NSMakeRange<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #002200;">&#91;</span>textString length<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>NSTextCheckingResult <span style="color: #002200;">*</span>result <span style="color: #a61390;">in</span> textArray<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// set color for range</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<br />
<span style="color: #11740a; font-style: italic;">// Comments</span><br />
expression <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSRegularExpression regularExpressionWithPattern<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;(//[^<span style="color: #2400d9;">\&quot;</span><span style="color: #2400d9;">\n</span>]*)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span> arrayComments <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>expression matchesInString<span style="color: #002200;">:</span>textString options<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span> range<span style="color: #002200;">:</span>NSMakeRange<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #002200;">&#91;</span>textString length<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>NSTextCheckingResult <span style="color: #002200;">*</span>resultComment <span style="color: #a61390;">in</span> arrayComments<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #a61390;">BOOL</span> inside <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>NSTextCheckingResult <span style="color: #002200;">*</span>resultText <span style="color: #a61390;">in</span> textArray<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NSInteger from <span style="color: #002200;">=</span> resultText.range.location;<br />
&nbsp; &nbsp; &nbsp; &nbsp; NSInteger to <span style="color: #002200;">=</span> resultText.range.location<span style="color: #002200;">+</span>resultText.range.length;<br />
&nbsp; &nbsp; &nbsp; &nbsp; NSInteger now <span style="color: #002200;">=</span> resultComment.range.location;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>from &lt; now <span style="color: #002200;">&amp;&amp;</span> now &lt; to<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inside <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>inside<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// set color for range</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/nsregularexpression-sample-for-comment-syntax-highlighting.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding SVN revision to Xcode project</title>
		<link>http://www.developers-life.com/adding-svn-revision-to-xcode-project.html</link>
		<comments>http://www.developers-life.com/adding-svn-revision-to-xcode-project.html#comments</comments>
		<pubDate>Wed, 23 Feb 2011 12:43:01 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1193</guid>
		<description><![CDATA[Просмотр ревизии в самом приложении предотвращает путаницу и всякие проблемы с отслеживанием текущей версии. Чтоб отслеживать версию репозитория нам нужно добавить слдеющий код bash скрипта. 12345678910REVISION=`svnversion -nc &#124; /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'` APPVERSION=`/usr/libexec/PlistBuddy -c &#34;Print CFBundleVersion&#34; &#34;${TARGET_BUILD_DIR}&#34;/${INFOPLIST_PATH}` xported=&#34;xported&#34; if &#91; $APPVERSION != $xported &#93;; then &#160; &#160; &#160;/usr/libexec/PlistBuddy -c &#34;Delete :CFBundleDisplayVersion&#34; &#34;${TARGET_BUILD_DIR}&#34;/${INFOPLIST_PATH} &#160; &#160; &#160;/usr/libexec/PlistBuddy -c [...]]]></description>
			<content:encoded><![CDATA[<p>Просмотр ревизии в самом приложении предотвращает путаницу и всякие проблемы с отслеживанием текущей версии.</p>
<p>Чтоб отслеживать версию репозитория нам нужно добавить слдеющий код bash скрипта.</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">REVISION</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">svnversion</span> <span style="color: #660033;">-nc</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/^[^:]*://;s/[A-Za-z]//'</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #007800;">APPVERSION</span>=<span style="color: #000000; font-weight: bold;">`/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Print CFBundleVersion&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TARGET_BUILD_DIR}</span>&quot;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${INFOPLIST_PATH}</span><span style="color: #000000; font-weight: bold;">`</span><br />
<br />
<span style="color: #007800;">xported</span>=<span style="color: #ff0000;">&quot;xported&quot;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$APPVERSION</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #007800;">$xported</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Delete :CFBundleDisplayVersion&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TARGET_BUILD_DIR}</span>&quot;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${INFOPLIST_PATH}</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Add :CFBundleDisplayVersion string&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TARGET_BUILD_DIR}</span>&quot;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${INFOPLIST_PATH}</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Set :CFBundleDisplayVersion <span style="color: #007800;">$APPVERSION</span>.<span style="color: #007800;">$REVISION</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TARGET_BUILD_DIR}</span>&quot;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${INFOPLIST_PATH}</span><br />
<span style="color: #000000; font-weight: bold;">fi</span></div></td></tr></tbody></table></div>
<p>Чтоб добавить скрипт, необходимо выполнить следующие действия:<br />
1. Зажать Ctrl+клик на фаил проекта в дереве проекта<br />
2. Add->New Build Phase -> New Run Script Build Phase<br />
3. Откроется окно в которое нужно вставить скрипт.</p>
<p><span id="more-1193"></span></p>
<p>В самом проекте, пример на сплеш скрине, создаем лейбл и читаем версию программы к примеру как-то так.</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>version <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Version &quot;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> objectForInfoDictionaryKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleDisplayVersion&quot;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>version stringByAppendingString<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> objectForInfoDictionaryKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleDisplayVersion&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p><img src="http://gyazo.com/150e15a5c21dbae21bcb6d5026220da2.png" alt="Adding SVN revision to Xcode project" /></p>
<p>Существует и второй вариант, более простой. (На самом деле можно придумать еще много разных способов.) Добавляем следующий bash скрипт в проект и добавляем фаил revision.h.</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">REV</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">svnversion</span> -n<span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;#define kRevisionNumber @<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$REV</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${PROJECT_DIR}</span><span style="color: #000000; font-weight: bold;">/</span>revision.h</div></td></tr></tbody></table></div>
<p>Желательно фаил вставить в один какой-то дальний хидер, чтоб при компилировании не пересобирался весь проект. </p>
<p>Для этого варианта можно написать что-то типа этого:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>version <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Version &quot;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> objectForInfoDictionaryKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleVersion&quot;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>version stringByAppendingString<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> objectForInfoDictionaryKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleVersion&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>version stringByAppendingString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;.&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>version stringByAppendingString<span style="color: #002200;">:</span>kRevisionNumber<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/adding-svn-revision-to-xcode-project.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RegexKitLite &#8211; Lightweight Objective-C Regular Expressions for Mac OS X and iPhone</title>
		<link>http://www.developers-life.com/regexkitlite-lightweight-objective-c-regular-expressions-for-mac-os-x-and-iphone.html</link>
		<comments>http://www.developers-life.com/regexkitlite-lightweight-objective-c-regular-expressions-for-mac-os-x-and-iphone.html#comments</comments>
		<pubDate>Wed, 25 Nov 2009 23:18:40 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=678</guid>
		<description><![CDATA[Very simple installation and in usage. Installation in iPhone project: 1. Add files RegexKitLite.h and RegexKitLite.m to project. 2. Open Target of project and add -licucore in Other Linker Flags 3. Compile Example: Remove tags from web-page. 1NSString *text = &#160;&#91;content stringByReplacingOccurrencesOfRegex:@&#34;&#60;.*&#62;&#34; withString:@&#34;&#34;&#93;; Site resource]]></description>
			<content:encoded><![CDATA[<p>Very simple installation and in usage.</p>
<p>Installation in iPhone project:<br />
1. Add files RegexKitLite.h and RegexKitLite.m to project.<br />
2. Open Target of project and add <em>-licucore</em> in <em>Other Linker Flags</em><br />
<img class="alignnone" src="http://gyazo.com/acca5c934defea76e4582410637d58a2.png" alt="" width="457" height="380" /><br />
3. Compile</p>
<p>Example:<br />
Remove tags from web-page.</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>text <span style="color: #002200;">=</span> &nbsp;<span style="color: #002200;">&#91;</span>content stringByReplacingOccurrencesOfRegex<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&lt;.*&gt;&quot;</span> withString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p><a href="http://regexkit.sourceforge.net/RegexKitLite/"><strong>Site resource</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/regexkitlite-lightweight-objective-c-regular-expressions-for-mac-os-x-and-iphone.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Проверка регулярных выражений</title>
		<link>http://www.developers-life.com/checking-regular-expressions.html</link>
		<comments>http://www.developers-life.com/checking-regular-expressions.html#comments</comments>
		<pubDate>Wed, 03 Sep 2008 17:00:56 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://developers-life.com/?p=12</guid>
		<description><![CDATA[Проверка регулярных выражений на онлайн сервисах. Очень удобный онлайн сервис по адресу http://www.regexpal.com/ не требует перезагрузки страницы для проверки регулярного выражения, написан полностью на javascript. Планрую на своем сайте создать подобный онлайн сервис. Еще один неплохой сервис проверки, но минус его в том, что необходимо перегружать страницу, а плюс в том, что он выводит результаты, [...]]]></description>
			<content:encoded><![CDATA[<p>Проверка регулярных выражений на онлайн сервисах.</p>
<p>Очень удобный онлайн сервис по адресу http://www.regexpal.com/ не требует перезагрузки страницы для проверки регулярного выражения, написан полностью на javascript. Планрую на своем сайте создать подобный онлайн сервис.</p>
<p>Еще один неплохой сервис проверки, но минус его в том, что необходимо перегружать страницу, а плюс в том, что он выводит результаты, что очень удобно при работе.Плюс есть шпаргалка, но к сожалению она не полная :( http://regexpr.ru/<br />
<span id="more-12"></span><br />
Пример написанных и оттестеных регулярных выражений, написанных мною, которые я использовал при написании на PHP. В данном случае нужно было парсить всю страницу и добавлять клинкам строку.</p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$text</span> <span style="color: #339933;">=</span>  <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&amp;lt;a(.*)href=([<span style="color: #000099; font-weight: bold;">\&quot;</span>']??)(www\.|http:\/\/www\.|http:\/\/)(&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'\.'</span><span style="color: #339933;">,</span><span style="color: #000088;">$home_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)([^\s]+)#([a-zA-Z0-9][a-zA-Z0-9<span style="color: #006699; font-weight: bold;">$_</span>+=-]{0,1000})[<span style="color: #000099; font-weight: bold;">\&quot;</span>'](.*)&amp;gt;(.*)&amp;lt;\/a&amp;gt;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;lt;a href=&quot;fr/#&quot; &amp;gt;&amp;lt;/a&amp;gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span>  <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&amp;lt;a(.*)href=([<span style="color: #000099; font-weight: bold;">\&quot;</span>']??)(www\.|http:\/\/www\.|http:\/\/)(&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'\.'</span><span style="color: #339933;">,</span><span style="color: #000088;">$home_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)([^\s#\?]+)[<span style="color: #000099; font-weight: bold;">\&quot;</span>'](.*)&amp;gt;(.*)&amp;lt;\/a&amp;gt;/siU&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;lt;a href=&quot;fr/&quot; &amp;gt;&amp;lt;/a&amp;gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span>  <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&amp;lt;a(.*)href=([<span style="color: #000099; font-weight: bold;">\&quot;</span>']??)(www\.|http:\/\/www\.|http:\/\/)(&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'\.'</span><span style="color: #339933;">,</span><span style="color: #000088;">$home_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)([^\s#]+)\?([^\s#]+)[<span style="color: #000099; font-weight: bold;">\&quot;</span>'](.*)&amp;gt;(.*)&amp;lt;\/a&amp;gt;/siU&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;lt;a href=&quot;?&amp;amp;lang_pref=fr&quot; &amp;gt;&amp;lt;/a&amp;gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><span style="font-size: small;">Разбить на предложения по спец символам </span></p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/([^.])+/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$authordata</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>user_description<span style="color: #339933;">,</span><span style="color: #000088;">$out</span><span style="color: #339933;">,</span>PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/checking-regular-expressions.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Parsing HTML to find Links</title>
		<link>http://www.developers-life.com/php-parsing-html-to-find-links.html</link>
		<comments>http://www.developers-life.com/php-parsing-html-to-find-links.html#comments</comments>
		<pubDate>Wed, 03 Sep 2008 16:56:00 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://developers-life.com/?p=10</guid>
		<description><![CDATA[Парсинг HTML, поиск линков Using the default for preg_match_all the array returned contains an array of the first &#8216;capture&#8217; then an array of the second capture and so forth. By capture we mean patterns contained in (): # Original PHP code by Chirp Internet: www.chirp.com.au # Please acknowledge use of this code by including this [...]]]></description>
			<content:encoded><![CDATA[<p>Парсинг HTML, поиск линков<br />
Using the default for preg_match_all the array returned contains an array of the first &#8216;capture&#8217; then an array of the second capture and so forth. By capture we mean patterns contained in <tt>()</tt>:</p>
<p> # Original <em>PHP</em> code by Chirp Internet: www.chirp.com.au   # Please acknowledge use of this code by including this header.</p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example.net/somepage.html&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not access file: $url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$regexp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a\s[^&gt;]*href=(<span style="color: #000099; font-weight: bold;">\&quot;</span>??)([^<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt;]*?)<span style="color: #660099; font-weight: bold;">\1</span>[^&gt;]*&gt;(.*)&lt;\/a&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$regexp</span>/siU&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;"># $matches[2] = array of link addresses<br />
</span><span style="color: #666666; font-style: italic;"># $matches[3] = array of link text - including HTML code<br />
</span><span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><span id="more-10"></span></p>
<p>Using <tt>PREG_SET_ORDER</tt> each link matched has it&#8217;s own array in the return value:</p>
<p> # Original <em>PHP</em> code by Chirp Internet: www.chirp.com.au   # Please acknowledge use of this code by including this header.</p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example.net/somepage.html&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not access file: $url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$regexp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a\s[^&gt;]*href=(<span style="color: #000099; font-weight: bold;">\&quot;</span>??)([^<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt;]*?)<span style="color: #660099; font-weight: bold;">\1</span>[^&gt;]*&gt;(.*)&lt;\/a&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$regexp</span>/siU&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># $match[2] = link address<br />
</span> &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># $match[3] = link text<br />
</span> &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>If you find any cases where this code falls down, let us know using the Feedback link below.</p>
<h2 id="section_5">First checking robots.txt</h2>
<p>As mentioned above, before using <em>a</em> script to download files you should <strong>always</strong> check the relevant <tt>robots.txt</tt> file.  Here we&#8217;re making use of the <tt>robots_allowed</tt> function from the article linked above to determine whether we&#8217;re allowed to access the file:</p>
<p># Original <em>PHP</em> code by Chirp Internet: www.chirp.com.au   # Please acknowledge use of this code by including this header.</p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><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 />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/ini_set"><span style="color: #990000;">ini_set</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_agent'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'NameOfAgent (http://www.example.net)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example.net/somepage.html&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>robots_allowed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;NameOfAgent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not access file: $url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$regexp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a\s[^&gt;]*href=(<span style="color: #000099; font-weight: bold;">\&quot;</span>??)([^<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt;]*?)<span style="color: #660099; font-weight: bold;">\1</span>[^&gt;]*&gt;(.*)&lt;\/a&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$regexp</span>/siU&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># $match[2] = link address<br />
</span> &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># $match[3] = link text<br />
</span> &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Access denied by robots.txt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/php-parsing-html-to-find-links.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

