codrgii Posted April 18, 2011 Share Posted April 18, 2011 Would someone tell me how to allow foreign letters, normal english letters and numbers using the preg_replace php function? Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/ Share on other sites More sharing options...
codrgii Posted April 18, 2011 Author Share Posted April 18, 2011 I forgot to add, these foreign letters are like í and so on. Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1203037 Share on other sites More sharing options...
dcro2 Posted April 18, 2011 Share Posted April 18, 2011 Add '\pL' or '\p{L}' to match unicode letters. You also have to set the 'u' (for utf- pattern modifier. /[\p{L}a-z0-9]/iu http://www.php.net/manual/en/regexp.reference.unicode.php Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1203172 Share on other sites More sharing options...
codrgii Posted April 20, 2011 Author Share Posted April 20, 2011 I tried your example but when i do, nothing shows, not even the basic a-z or numbers. Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1204112 Share on other sites More sharing options...
dcro2 Posted April 21, 2011 Share Posted April 21, 2011 It wasn't meant to be plug and play... I don't know what you're trying to replace or allow, I was just showing you an example. Maybe if you post the code and what you're trying to do... Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1204341 Share on other sites More sharing options...
codrgii Posted April 21, 2011 Author Share Posted April 21, 2011 Would someone tell me how to allow foreign letters, normal english letters and numbers using the preg_replace php function? It says it all there. I want to only allow the basic English letters and words a-z0-9 but with that also allow foreign accent letters, then remove anything else. Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1204376 Share on other sites More sharing options...
dcro2 Posted April 25, 2011 Share Posted April 25, 2011 So you want to remove anything that's NOT one of these characters? Use ^ $string = preg_replace("/[^\p{L}a-z0-9]/iu", "", $string); Remember that space is included... Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1206157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.