<?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: PHP and Regex &#8211; Replacing Repeating Characters with Single Characters in a String</title>
	<atom:link href="http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/</link>
	<description>David Drake Covers Programming, Technology and Turbulence in Life</description>
	<lastBuildDate>Sat, 04 Feb 2012 20:52:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ibrahim</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-24636</link>
		<dc:creator>Ibrahim</dc:creator>
		<pubDate>Wed, 19 May 2010 06:13:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-24636</guid>
		<description>If we are using loop in regx, then how would it be faster than str_replace function?
Thanks,</description>
		<content:encoded><![CDATA[<p>If we are using loop in regx, then how would it be faster than str_replace function?<br />
Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Nicolini</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-21993</link>
		<dc:creator>Pete Nicolini</dc:creator>
		<pubDate>Tue, 30 Mar 2010 21:22:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-21993</guid>
		<description>little bit of it I have you bookmarked so I can find your latest posts</description>
		<content:encoded><![CDATA[<p>little bit of it I have you bookmarked so I can find your latest posts</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prema</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-19024</link>
		<dc:creator>Prema</dc:creator>
		<pubDate>Mon, 08 Feb 2010 07:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-19024</guid>
		<description>PHP String functions to eliminate repeating character


$string = &quot;1122337749903&quot;;
$value = count_chars($string, 3);
echo $value; //12374903</description>
		<content:encoded><![CDATA[<p>PHP String functions to eliminate repeating character</p>
<p>$string = &#8220;1122337749903&#8243;;<br />
$value = count_chars($string, 3);<br />
echo $value; //12374903</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raj</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-13440</link>
		<dc:creator>raj</dc:creator>
		<pubDate>Thu, 10 Sep 2009 20:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-13440</guid>
		<description>hot to find the first duplicate character in a given string.
e.g., abccccdddeee
 out put should be
c

plz help me out</description>
		<content:encoded><![CDATA[<p>hot to find the first duplicate character in a given string.<br />
e.g., abccccdddeee<br />
 out put should be<br />
c</p>
<p>plz help me out</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lonnie Coffman</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-11707</link>
		<dc:creator>Lonnie Coffman</dc:creator>
		<pubDate>Wed, 22 Jul 2009 09:57:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-11707</guid>
		<description>Mode number 3 for the count_chars function returns a string containing all unique characters.  If you run the code it will return &#039;abcdef&#039; not &#039;abcadaef&#039;.

You are correct that it does not preserve order though.  The results are returned in alphabetical order.</description>
		<content:encoded><![CDATA[<p>Mode number 3 for the count_chars function returns a string containing all unique characters.  If you run the code it will return &#8216;abcdef&#8217; not &#8216;abcadaef&#8217;.</p>
<p>You are correct that it does not preserve order though.  The results are returned in alphabetical order.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-11685</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 21 Jul 2009 21:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-11685</guid>
		<description>Actually, no, this will not work.

The desired return string from your input (aabbccaaaaddaaeeff), would be:
abcadaef

The count_chars function only returns all the individual characters used without repeats and does not preserve order:
abcdef

Close -- but no cigar.</description>
		<content:encoded><![CDATA[<p>Actually, no, this will not work.</p>
<p>The desired return string from your input (aabbccaaaaddaaeeff), would be:<br />
abcadaef</p>
<p>The count_chars function only returns all the individual characters used without repeats and does not preserve order:<br />
abcdef</p>
<p>Close &#8212; but no cigar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lonnie Coffman</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-11684</link>
		<dc:creator>Lonnie Coffman</dc:creator>
		<pubDate>Tue, 21 Jul 2009 20:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-11684</guid>
		<description>Using PHP this can be accomplished easily using the count_chars() function:

$string = &#039;aabbccaaaaddaaeeff&#039;;
$value = count_chars($string, 3);
echo $value;</description>
		<content:encoded><![CDATA[<p>Using PHP this can be accomplished easily using the count_chars() function:</p>
<p>$string = &#8216;aabbccaaaaddaaeeff&#8217;;<br />
$value = count_chars($string, 3);<br />
echo $value;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: استفسار بخصوص تكرار الأحرف ! - سوالف سوفت</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-8705</link>
		<dc:creator>استفسار بخصوص تكرار الأحرف ! - سوالف سوفت</dc:creator>
		<pubDate>Wed, 06 May 2009 04:15:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-8705</guid>
		<description>[...] الانجليزيه بالعربيه بالكود وراح يكون تمام ان شاء الله PHP and Regex - Replacing Repeating Characters with Single Characters in a String &#124; I Love Bonnie.ne...  و FLEX{er}   موفق..    __________________ سبحان الله وبحمده  مجموعة [...]</description>
		<content:encoded><![CDATA[<p>[...] الانجليزيه بالعربيه بالكود وراح يكون تمام ان شاء الله PHP and Regex &#8211; Replacing Repeating Characters with Single Characters in a String | I Love Bonnie.ne&#8230;  و FLEX{er}   موفق..    __________________ سبحان الله وبحمده  مجموعة [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jette D.</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-4207</link>
		<dc:creator>Jette D.</dc:creator>
		<pubDate>Wed, 19 Nov 2008 12:47:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-4207</guid>
		<description>For user input I need people to be able to write &#039;apple&#039; or &#039;haaalleluja&#039;. Therefore stripping any repetition is a bit too strict for my purpose. So I use this one to prevent chars repeated more than 3 times with any whitespace (prior to this, I strip any whitespace down to only one at a time):

preg_replace(&#039;{( ?.)\1{4,}}&#039;,&#039;$1$1$1&#039;,$str);

The info on this page was a great inspiration for this... Thanks! :-)</description>
		<content:encoded><![CDATA[<p>For user input I need people to be able to write &#8216;apple&#8217; or &#8216;haaalleluja&#8217;. Therefore stripping any repetition is a bit too strict for my purpose. So I use this one to prevent chars repeated more than 3 times with any whitespace (prior to this, I strip any whitespace down to only one at a time):</p>
<p>preg_replace(&#8216;{( ?.)\1{4,}}&#8217;,'$1$1$1&#8242;,$str);</p>
<p>The info on this page was a great inspiration for this&#8230; Thanks! <img src='http://randomdrake.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://randomdrake.com/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/comment-page-1/#comment-572</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Wed, 23 Apr 2008 16:51:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=35#comment-572</guid>
		<description>Thanks for the discussion and the help TLP. I updated the post to reflect your better version.</description>
		<content:encoded><![CDATA[<p>Thanks for the discussion and the help TLP. I updated the post to reflect your better version.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.152 seconds -->

