<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Limit string using regex with PHP</title>
	<atom:link href="http://jeffri.net/2009/02/limit-string-using-regex-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/</link>
	<description> </description>
	<lastBuildDate>Fri, 03 Feb 2012 18:47:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: andre</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-4336</link>
		<dc:creator>andre</dc:creator>
		<pubDate>Thu, 09 Dec 2010 03:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-4336</guid>
		<description>nice info.. it helps me alot. thx again</description>
		<content:encoded><![CDATA[<p>nice info.. it helps me alot. thx again</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rangga</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-3196</link>
		<dc:creator>rangga</dc:creator>
		<pubDate>Sat, 29 May 2010 13:01:58 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-3196</guid>
		<description>thanks gan :)</description>
		<content:encoded><![CDATA[<p>thanks gan <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keaglez</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-1582</link>
		<dc:creator>keaglez</dc:creator>
		<pubDate>Wed, 15 Jul 2009 06:38:14 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-1582</guid>
		<description>do you mean to take the first 4 digit numbers from string? if that so, then try this pattern

$pattern = &quot;/^[^0-9]*(\d{1,4}).*$/&quot;;

It needs to match from the beginning of string, so we can extract the needed part with preg_replace. We can, however, use preg_match and get required string using reference variable that passed into the third parameter. For example:

$string = &quot;dfd4534565465fher5645g&quot;;
$pattern = &quot;/(\d{1,4})/&quot;;
preg_match($pattern, $string, $match);
echo $match[1];

This is far easier, since regex search from beginning, we only need to look for 4 digits, and it will took the first 4 digits it matched... :) Hope it useful for you... ;)</description>
		<content:encoded><![CDATA[<p>do you mean to take the first 4 digit numbers from string? if that so, then try this pattern</p>
<p>$pattern = &#8220;/^[^0-9]*(\d{1,4}).*$/&#8221;;</p>
<p>It needs to match from the beginning of string, so we can extract the needed part with preg_replace. We can, however, use preg_match and get required string using reference variable that passed into the third parameter. For example:</p>
<p>$string = &#8220;dfd4534565465fher5645g&#8221;;<br />
$pattern = &#8220;/(\d{1,4})/&#8221;;<br />
preg_match($pattern, $string, $match);<br />
echo $match[1];</p>
<p>This is far easier, since regex search from beginning, we only need to look for 4 digits, and it will took the first 4 digits it matched&#8230; <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Hope it useful for you&#8230; <img src='http://jeffri.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Garchagudashvili</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-1580</link>
		<dc:creator>George Garchagudashvili</dc:creator>
		<pubDate>Tue, 14 Jul 2009 12:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-1580</guid>
		<description>Hey very nice ya, but what about if we need to take 4 digits from the string and not matter from what part 
$string = &quot;dfd4534565465fher5645g&quot;;
$pattern = &quot;/(\d{1,5}[^\s]{0}).*$/&quot;;
echo preg_replace($pattern,&quot;\\1&quot;,$string);
i got 5 digits but also first &#039;dfd&#039; from the string, i hope youcan help me.
Thanks</description>
		<content:encoded><![CDATA[<p>Hey very nice ya, but what about if we need to take 4 digits from the string and not matter from what part<br />
$string = &#8220;dfd4534565465fher5645g&#8221;;<br />
$pattern = &#8220;/(\d{1,5}[^\s]{0}).*$/&#8221;;<br />
echo preg_replace($pattern,&#8221;\\1&#8243;,$string);<br />
i got 5 digits but also first &#8216;dfd&#8217; from the string, i hope youcan help me.<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keaglez</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-1342</link>
		<dc:creator>keaglez</dc:creator>
		<pubDate>Sat, 09 May 2009 20:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-1342</guid>
		<description>Glad if it useful for you. :)</description>
		<content:encoded><![CDATA[<p>Glad if it useful for you. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ghprod</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-1336</link>
		<dc:creator>ghprod</dc:creator>
		<pubDate>Thu, 07 May 2009 17:10:13 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-1336</guid>
		<description>great tutorial ... simple and full with function:)

thnx

regards</description>
		<content:encoded><![CDATA[<p>great tutorial &#8230; simple and full with function:)</p>
<p>thnx</p>
<p>regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Benson</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-1252</link>
		<dc:creator>Sam Benson</dc:creator>
		<pubDate>Sun, 19 Apr 2009 09:29:51 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-1252</guid>
		<description>Regex makes my brain melt - this was really handy. Thanks!</description>
		<content:encoded><![CDATA[<p>Regex makes my brain melt &#8211; this was really handy. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Petrov</title>
		<link>http://jeffri.net/2009/02/limit-string-using-regex-with-php/#comment-1179</link>
		<dc:creator>Philip Petrov</dc:creator>
		<pubDate>Mon, 09 Mar 2009 11:12:12 +0000</pubDate>
		<guid isPermaLink="false">http://jeffri.net/?p=219#comment-1179</guid>
		<description>Very good. You did a nice tutorial here!</description>
		<content:encoded><![CDATA[<p>Very good. You did a nice tutorial here!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

