Jeff Cloud
Jeff Cloud

Reputation: 13

Remove '%' from string using preg_replace()

How do I remove % from a string using preg_replace function?

Here is what I currently have, but the % sign is blocking the twitter share button from processing:

<div class="twitter">
<a href="http://twitter.com/share?text=Just%20Sorc\'d:%20%20'. preg_replace('/((?:http|https|ftp):\/\/(?:[A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?[^\s\"\']+)/i','<a href="$1" rel="nofollow" target="blank">$1</a>',$post).'%20--%20via:%20%20http://www.sorcd.com/'.$session_user_id.'%20%20at%20%20" target="_blank" data-count="none"><img src="https://abs.twimg.com/a/1378977615/images/resources/twitter-bird-white-on-blue.png" width="16px" alt="Tweet"></a>
</div>

Upvotes: 1

Views: 311

Answers (2)

Xu Huafu
Xu Huafu

Reputation: 19

You can use urldecode() to decode it. '%20' means space

Upvotes: 0

Vikas Arora
Vikas Arora

Reputation: 1666

Firstly, Your string/URL has URI encoded values like %20 which means they are spaces. Removing % will not solve the problem.

Secondly, this is a possible duplicate of how-to-remove-sign-in-php-string.

Upvotes: 1

Related Questions