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? Quote 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. Quote 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 Quote 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. Quote 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... Quote 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. Quote 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... Quote Link to comment https://forums.phpfreaks.com/topic/234059-allowing-foreign-letters/#findComment-1206157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.