<?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>LAMPdocs: Linux, Apache, MySQL, PHP &#187; Regexps</title>
	<atom:link href="http://www.lampdocs.com/blog/category/regexps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lampdocs.com/blog</link>
	<description>Linux, Apache, MySQL, PHP: Docs, Tricks and Secrets</description>
	<lastBuildDate>Wed, 04 Jan 2012 13:11:27 +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>Regular Expression to Validate URLs</title>
		<link>http://www.lampdocs.com/blog/2010/02/regular-expression-to-validate-urls/</link>
		<comments>http://www.lampdocs.com/blog/2010/02/regular-expression-to-validate-urls/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 15:20:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Solutions]]></category>
		<category><![CDATA[Regexps]]></category>
		<category><![CDATA[php url form validation]]></category>
		<category><![CDATA[regular expression url]]></category>
		<category><![CDATA[validate url php]]></category>

		<guid isPermaLink="false">http://www.lampdocs.com/blog/?p=859</guid>
		<description><![CDATA[Regular expression used to validate URLs]]></description>
			<content:encoded><![CDATA[<p>Here is a short regexp that is used to validate whether a user has entered correct URL address. Might be useful in any scripts dealing with user data.</p>
<p>I will show it as PHP code:</p>
<blockquote><p>preg_match(&#8216;/^(http:\/\/|https:\/\/)([^\.\/]+\.)*([a-zA-Z0-9])([a-zA-Z0-9-]*)\.([a-zA-Z]{2,4})(\/.*)?$/i&#8217;, $_POST['url']);</p></blockquote>
<p>It will check whether url suits the pattern. May not be ideal, but it&#8217;s working. <img src='http://www.lampdocs.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampdocs.com/blog/2010/02/regular-expression-to-validate-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expression to Extract all E-mail Addresses from a File With PHP</title>
		<link>http://www.lampdocs.com/blog/2008/10/regular-expression-to-extract-all-e-mail-addresses-from-a-file-with-php/</link>
		<comments>http://www.lampdocs.com/blog/2008/10/regular-expression-to-extract-all-e-mail-addresses-from-a-file-with-php/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 09:26:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Solutions]]></category>
		<category><![CDATA[Regexps]]></category>
		<category><![CDATA[e-mail pattern regexp]]></category>
		<category><![CDATA[extract e-mails from page]]></category>
		<category><![CDATA[extract email regular expression]]></category>
		<category><![CDATA[parse e-mails]]></category>
		<category><![CDATA[pattern for valid e-mail]]></category>
		<category><![CDATA[php e-mail extractor]]></category>
		<category><![CDATA[php extract email from text file]]></category>
		<category><![CDATA[php parse e-mails]]></category>
		<category><![CDATA[regex parse email addresses php]]></category>
		<category><![CDATA[valid e-mail regular expression]]></category>

		<guid isPermaLink="false">http://www.lampdocs.com/blog/?p=198</guid>
		<description><![CDATA[Sometimes you need to extract some data from text files. E-mails, passwords, just some simple tags&#8230; no matter what it is, your best choice to do this is to use regular expressions. I will show you a PHP script that will extract all valid e-mails from a text file. &#60;? $fs=fopen(&#8220;best.txt&#8221;, &#8220;r&#8221;); $f3=fopen(&#8220;clean.txt&#8221;, &#8220;a&#8221;); while(!feof($fs)) [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to extract some data from text files. E-mails, passwords, just some simple tags&#8230; no matter what it is, your best choice to do this is to use regular expressions. I will show you a PHP script that will extract all valid e-mails from a text file.</p>
<blockquote><p>&lt;?<br />
$fs=fopen(&#8220;best.txt&#8221;, &#8220;r&#8221;);</p>
<p>$f3=fopen(&#8220;clean.txt&#8221;, &#8220;a&#8221;);<br />
while(!feof($fs))<br />
{<br />
$gan=fgets($fs);<br />
preg_match(&#8220;/[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))/&#8221;, $gan, $matches);<br />
fwrite($f3, trim($matches[0]).&#8221;\r\n&#8221;);<br />
}<br />
fclose($f3);<br />
fclose($fs);</p>
<p>?&gt;</p></blockquote>
<p>best.txt is a file containing valid e-mail addresses. clean.txt will contain e-mail addresses only. We&#8217;re checking every string of best.txt against a regular expression that represents a valid e-mail pattern. <strong>&#8220;/[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))/&#8221; </strong>is the pattern and I don&#8217;t think it is necessary to explain what does it mean. If you&#8217;re familiar with regular expressions, you&#8217;ll be able to modify it to find any specific e-mails. If not, you may use this example and you will find that it really works. There are some programs on the net, that are doing the same thing, but they work under Windows and don&#8217;t allow to process big files.</p>
<p>This script can work with big files, don&#8217;t forget to set time limit to 0 (I have this done in my php.ini). Happy parsing! <img src='http://www.lampdocs.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampdocs.com/blog/2008/10/regular-expression-to-extract-all-e-mail-addresses-from-a-file-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Regular Expression to Parse Text Between Simple Tags (XML)</title>
		<link>http://www.lampdocs.com/blog/2008/09/regular-expression-to-parse-text-between-simple-tags-xml/</link>
		<comments>http://www.lampdocs.com/blog/2008/09/regular-expression-to-parse-text-between-simple-tags-xml/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 09:02:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache Performance]]></category>
		<category><![CDATA[PHP Solutions]]></category>
		<category><![CDATA[Regexps]]></category>
		<category><![CDATA[how to parse xml php]]></category>
		<category><![CDATA[parse text between xml tags]]></category>
		<category><![CDATA[parse text within tags]]></category>
		<category><![CDATA[parse text xml php]]></category>
		<category><![CDATA[regular expression between html tag]]></category>

		<guid isPermaLink="false">http://www.lampdocs.com/blog/?p=162</guid>
		<description><![CDATA[It is often necessary to extract text from a variable that contains HTML or XML code. I&#8217;ve created a simple regular expression that will help you to extract all text between certain tags into an array. It is a PHP solution, though regular expression is compatible with other programming languages. preg_match_all(&#8220;/&#60;tag&#62;(.*?)&#60;\/tag&#62;/&#8221;, $source, $results); This construsion [...]]]></description>
			<content:encoded><![CDATA[<p>It is often necessary to extract text from a variable that contains HTML or XML code. I&#8217;ve created a simple regular expression that will help you to extract all text between certain tags into an array. It is a PHP solution, though regular expression is compatible with other programming languages.</p>
<p><strong>preg_match_all(&#8220;/&lt;tag&gt;(.*?)&lt;\/tag&gt;/&#8221;, $source, $results)</strong>;</p>
<p>This construsion will create an array with extracted data. All you need is to change &#8220;tag&#8221; to any tag you like. This string was created to parse xml files, but it will work for simple HTML tags without attributes too.</p>
<p>The function above will extract all occurences of regular expression match. $output will contain an array with the extracted values. Please, run var_dump to check what&#8217;s in this array</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampdocs.com/blog/2008/09/regular-expression-to-parse-text-between-simple-tags-xml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Preventing Bandwidth Leak With Correct Out URLs</title>
		<link>http://www.lampdocs.com/blog/2008/05/preventing-bandwidth-leak-with-correct-out-urls/</link>
		<comments>http://www.lampdocs.com/blog/2008/05/preventing-bandwidth-leak-with-correct-out-urls/#comments</comments>
		<pubDate>Wed, 21 May 2008 05:02:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Regexps]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[correct redirection]]></category>
		<category><![CDATA[prevent URL misuse]]></category>

		<guid isPermaLink="false">http://www.lampdocs.com/blog/?p=67</guid>
		<description><![CDATA[There is a common practice to use outgoing links from your site to track visitor activity. For example, your site is www.site.com, and external links look like www.site.com/out.php?url=http://anothersite.com . It is OK for counters and traffic tracking, but may be used for an uncommon way. It this sample you may replace http://anothersite.com with any other [...]]]></description>
			<content:encoded><![CDATA[<p>There is a common practice to use outgoing links from your site to track visitor activity. For example, your site is www.site.com, and external links look like www.site.com/out.php?url=http://anothersite.com . It is OK for counters and traffic tracking, but may be used for an uncommon way. It this sample you may replace http://anothersite.com with any other site and your site will redirect to it. Do you understand what can it be used for?</p>
<p>Spamming, phishing and other stuff like this often relies on such bugs. You may receive abuses from anybody because you cannot know what kind of sites will be promoted and what will be the way to do it.<br />
Even monsters, like Google and ADRiver have such a traffic leak. I recently found in my mailbox e-mails with links to:<br />
http://www.google.fr/pagead/SOME_PARAMS&#038;adurl=SPAMMER&#8217;s URL and http://ad.doubleclick.net/SOME_PARAMS?SPAMMER&#8217;s URL .<br />
How do you prevent such things? First of all, never use such a construction with url=http:// and so on. You can assign an unique id for each URL and store it into database or text file and create outgoing URLs with such IDs.  www.site.com/out.php?id=YOUR_ID will be much better and will save you from this malicious activity.</p>
<p>Be patient with standard scripts, as some of them contain such a vulnerability. For example, Autorank Pro and some other may contain such URL syntax. Have a nice day and make your URLs in a correct way!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampdocs.com/blog/2008/05/preventing-bandwidth-leak-with-correct-out-urls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Testing Regular Expressions Online</title>
		<link>http://www.lampdocs.com/blog/2008/05/testing-regular-expressions-online/</link>
		<comments>http://www.lampdocs.com/blog/2008/05/testing-regular-expressions-online/#comments</comments>
		<pubDate>Sat, 03 May 2008 12:29:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Regexps]]></category>
		<category><![CDATA[checking regexp]]></category>
		<category><![CDATA[free regular expression checker]]></category>
		<category><![CDATA[regexp check windows]]></category>
		<category><![CDATA[Regexp online]]></category>

		<guid isPermaLink="false">http://www.lampdocs.com/blog/?p=43</guid>
		<description><![CDATA[Just wanted to share some useful links with you. If you often use regular expressions, you might find useful to check them online or anywhere else before your code is executed. First of all, an Online Service that seems to be free: RegExr: Online Regular Expression Testing Tool It allows you to check whatever you [...]]]></description>
			<content:encoded><![CDATA[<p>Just wanted to share some useful links with you. If you often use regular expressions, you might find useful to check them online or anywhere else before your code is executed.</p>
<p>First of all, an Online Service that seems to be free: <a title="Checking Regular Expressions Online" href="http://gskinner.com/RegExr/">RegExr: Online Regular Expression Testing Tool</a> It allows you to check whatever you want and has most useful meta symbols built in.</p>
<p>If you are on Windows, you might like this tool: <a href="http://regexpstudio.com/TRegExpr/TRegExpr.html">TRegExpr</a> It allows you to check your code in Windows without the necessity to execute it first. Just paste a sample of the text you&#8217;re working with and check the results immediately. Software is written in Delphi and is free for personal use.</p>
<p>The next site is <a title="Sexy Regex" href="http://sexyregex.com/regex/test">Sexyregex.com</a>. You can find regex library there, so it is not just testing, but also giving you ideas for your own needs. </p>
<p>If you have any other interesting sites, you&#8217;re welcome to share them with me. Just let me know and I will add them to this page. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampdocs.com/blog/2008/05/testing-regular-expressions-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

