robbyc Posted February 18, 2007 Share Posted February 18, 2007 I have the following regex [A-Z][a-z]{3,}[in] I simply want to remove the i or the n off the end of the matches, i.e. Russian becomes Russian and Pakistani becomes Pakistan. Thanks Link to comment https://forums.phpfreaks.com/topic/39019-regex-replacement/ Share on other sites More sharing options...
Orio Posted February 18, 2007 Share Posted February 18, 2007 No regex needed... <?php $last = substr(trim($str), -1); if($last == 'n' || $last == 'i') $str = substr($str, 0, -1); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/39019-regex-replacement/#findComment-187886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.