Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to remove Registered, Trademark, and Copyright symbols from a string?

Tags:

string

php

What's the best way to remove symbols, like the Registered, Trademark, and Copyright symbols from a string?

For instance I'd like to strip the ® out of the following: $string = 'Can't Touch This®';

like image 908
hsatterwhite Avatar asked Jul 22 '10 02:07

hsatterwhite


People also ask

How do I remove the registered trademark symbol in Excel?

To remove it, go to Fle Tab | Options | Proofing | Click "Auto Correct Options..." button | click the (c) then Delete, same as the (r). Was this reply helpful?

How do you superscript a registered trademark?

Proper Placement of the Registered Trademark Symbol It's recommended that the registered trademark symbol be used in connection with all registered trademarks. It should either be placed to the lower right (subscript) or to the upper right (superscript) of the actual mark.


2 Answers

If you know what you want to remove, then use str_replace()

For instance:

 $my_string = str_replace(array('®', '™'), array('', ''), $my_string)

If you've got a long list of 'forbidden' characters, you could use array_fill(0, count($forbidden_list), '')

like image 77
staticsan Avatar answered Sep 20 '22 18:09

staticsan


$str = preg_replace("/(™|®|©|™|®|©|™|®|©)/", "", $str);
like image 34
Dr D Avatar answered Sep 17 '22 18:09

Dr D