简体   繁体   中英

how remove last special character from this string with preg_replace?

I want to remove this >

from

com.gau.go.launcherex.gowidget.weatherwidget>

To remove > you can use preg_replace() as

preg_replace('/[>$]/s', '', $str);

Output

com.gau.go.launcherex.gowidget.weatherwidget

Put the character before $ to match it at the end of the string.

$string = preg_replace('/>$/', '', $string);

To remove this > im used this code

rtrim($string,'&gt');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM