<?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: Strip non alphanumeric characters from a string with php</title>
	<atom:link href="http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Sat, 11 Feb 2012 05:27:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: theadsbook</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-961111</link>
		<dc:creator>theadsbook</dc:creator>
		<pubDate>Sat, 08 Oct 2011 20:15:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-961111</guid>
		<description>this is really very useful</description>
		<content:encoded><![CDATA[<p>this is really very useful</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roark</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-889625</link>
		<dc:creator>Roark</dc:creator>
		<pubDate>Thu, 28 Jul 2011 15:22:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-889625</guid>
		<description>Hi
Correct me if I&#039;m wrong... Isn&#039;t &#039;str_replace&#039; faster than any regular expression based function?</description>
		<content:encoded><![CDATA[<p>Hi<br />
Correct me if I&#8217;m wrong&#8230; Isn&#8217;t &#8216;str_replace&#8217; faster than any regular expression based function?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kht</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-884181</link>
		<dc:creator>kht</dc:creator>
		<pubDate>Thu, 21 Jul 2011 10:36:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-884181</guid>
		<description>Hi, 

this function allowed for space to leave alone, but how to limit only into single space?
so double or more space will removed?

thanks</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>this function allowed for space to leave alone, but how to limit only into single space?<br />
so double or more space will removed?</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rp pl</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-849221</link>
		<dc:creator>rp pl</dc:creator>
		<pubDate>Thu, 09 Jun 2011 11:54:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-849221</guid>
		<description>this is very good. Good work, it solves my problem. Thanks.</description>
		<content:encoded><![CDATA[<p>this is very good. Good work, it solves my problem. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seki</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-840661</link>
		<dc:creator>seki</dc:creator>
		<pubDate>Wed, 25 May 2011 04:33:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-840661</guid>
		<description>@Smith

the solution is already described above 
$username = (preg_replace(“/[^A-Za-z0-9\s\s+\-]/”, “”, $username));

I added \- because I assume you wish to allow for &quot;double or triple barrel names like John Smith-Brown.
An interesting situation arises when you have O&#039;Brien etc .. I remove the &#039; since it causes way more trouble than its worth. But if you want to include it simply add \&#039; to the masking string.</description>
		<content:encoded><![CDATA[<p>@Smith</p>
<p>the solution is already described above<br />
$username = (preg_replace(“/[^A-Za-z0-9\s\s+\-]/”, “”, $username));</p>
<p>I added \- because I assume you wish to allow for &#8220;double or triple barrel names like John Smith-Brown.<br />
An interesting situation arises when you have O&#8217;Brien etc .. I remove the &#8216; since it causes way more trouble than its worth. But if you want to include it simply add \&#8217; to the masking string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Smith</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-821099</link>
		<dc:creator>Smith</dc:creator>
		<pubDate>Wed, 27 Apr 2011 07:14:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-821099</guid>
		<description>Hello guys, is it possibile to replace white spaces with white spaces?

Example:
$name = John Smith

need to replace with preg_replace:

$username = $name;
$username = (preg_replace(&quot;/[^A-Za-z0-9-]/&quot;, &quot;&quot;, $username));

the result in my database is:
JohnSmith and i need 
John Smith  -- with white spaces inside

Thanks :)</description>
		<content:encoded><![CDATA[<p>Hello guys, is it possibile to replace white spaces with white spaces?</p>
<p>Example:<br />
$name = John Smith</p>
<p>need to replace with preg_replace:</p>
<p>$username = $name;<br />
$username = (preg_replace(&#8220;/[^A-Za-z0-9-]/&#8221;, &#8220;&#8221;, $username));</p>
<p>the result in my database is:<br />
JohnSmith and i need<br />
John Smith  &#8212; with white spaces inside</p>
<p>Thanks :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tihomir Ipotpaliev</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-685145</link>
		<dc:creator>Tihomir Ipotpaliev</dc:creator>
		<pubDate>Thu, 25 Nov 2010 09:52:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-685145</guid>
		<description>How about uft-8 coded chars, like .. ?,?,? ..</description>
		<content:encoded><![CDATA[<p>How about uft-8 coded chars, like .. ?,?,? ..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Qwerp</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-658668</link>
		<dc:creator>Qwerp</dc:creator>
		<pubDate>Wed, 13 Oct 2010 04:27:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-658668</guid>
		<description>Thanks! I&#039;ve been looking for this forever!</description>
		<content:encoded><![CDATA[<p>Thanks! I&#8217;ve been looking for this forever!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ComboFusion</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-649912</link>
		<dc:creator>ComboFusion</dc:creator>
		<pubDate>Thu, 30 Sep 2010 20:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-649912</guid>
		<description>I am trying to solve my problem with this line:

$new_string = preg_replace(“/[^A-Za-z0-9\s\s+\.\:\-\/%+\(\)\*\&amp;\$\#\!\@\&quot;\&#039;;\n\t\r]/”,”&quot;,$old_string);

Which works almost fine except for one thing. I am trying to leave characters like š???žŠ???Ž inside my $old_string, however they always get stripped.

I was thinking that the code below could work for my case, but it doesn&#039;t. Can anyone help me here please?

$new_string = preg_replace(&#039;/[^0-9a-z?-????\`\~\!\@\#\$\%\^\*\(\)\; \,\.\&#039;\/\_\-\š\?\?\?\ž\Š\?\?\?\Ž]/i&#039;, &#039;&#039;, $old_string);

I need to have this transformation:

Me \ and Peter Biš?ak =&gt; Me and Peter Biš?ak

Thank you so much in advance.</description>
		<content:encoded><![CDATA[<p>I am trying to solve my problem with this line:</p>
<p>$new_string = preg_replace(“/[^A-Za-z0-9\s\s+\.\:\-\/%+\(\)\*\&amp;\$\#\!\@\"\';\n\t\r]/”,”&#8221;,$old_string);</p>
<p>Which works almost fine except for one thing. I am trying to leave characters like š???žŠ???Ž inside my $old_string, however they always get stripped.</p>
<p>I was thinking that the code below could work for my case, but it doesn&#8217;t. Can anyone help me here please?</p>
<p>$new_string = preg_replace(&#8216;/[^0-9a-z?-????\`\~\!\@\#\$\%\^\*\(\)\; \,\.\'\/\_\-\š\?\?\?\ž\Š\?\?\?\Ž]/i&#8217;, &#8221;, $old_string);</p>
<p>I need to have this transformation:</p>
<p>Me \ and Peter Biš?ak =&gt; Me and Peter Biš?ak</p>
<p>Thank you so much in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhijeet</title>
		<link>http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-640114</link>
		<dc:creator>Abhijeet</dc:creator>
		<pubDate>Tue, 14 Sep 2010 04:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/#comment-640114</guid>
		<description>$search = preg_replace(&quot;/[^A-Za-z0-9\s\s+]/&quot;,&quot; &quot;,$search);
is always suitable.

php.net warning 
ereg_replace : This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. 
http://php.net/manual/en/function.ereg-replace.php</description>
		<content:encoded><![CDATA[<p>$search = preg_replace(&#8220;/[^A-Za-z0-9\s\s+]/&#8221;,&#8221; &#8220;,$search);<br />
is always suitable.</p>
<p>php.net warning<br />
ereg_replace : This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.<br />
<a href="http://php.net/manual/en/function.ereg-replace.php" rel="nofollow">http://php.net/manual/en/function.ereg-replace.php</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 6/11 queries in 0.031 seconds using disk: basic

Served from: www.emanueleferonato.com @ 2012-02-11 13:52:37 -->
