codrgii Posted May 29, 2011 Share Posted May 29, 2011 Using the preg_replace function, how can i enable the use of Latin a-b letters alongwith basic english a-z and without jeopardising security? just to be clear i would like to only allow Latin a-b characters and english a-z removing anything else if anyone is unsure what Latin a-b characters are then goto http://en.wikipedia.org/wiki/List_of_Unicode_characters Link to comment https://forums.phpfreaks.com/topic/237736-filtering/ Share on other sites More sharing options...
codrgii Posted May 29, 2011 Author Share Posted May 29, 2011 is it possible? Link to comment https://forums.phpfreaks.com/topic/237736-filtering/#findComment-1221879 Share on other sites More sharing options...
wildteen88 Posted May 29, 2011 Share Posted May 29, 2011 You mean something like this $str = '$#La souri$<<>-//s a été mangée par le chat '; $str = preg_replace('/[^\p{L}\s-]/u', '', $str); echo $str; //Outputs La souri-s a été mangée par le chat This is not my code. I found a similar question here http://stackoverflow.com/questions/3436746/help-with-preg-replace-and-special-chars Link to comment https://forums.phpfreaks.com/topic/237736-filtering/#findComment-1221887 Share on other sites More sharing options...
xyph Posted May 29, 2011 Share Posted May 29, 2011 [^\p{L}\p{M}\p{Z}\p{N}] Match a single character NOT present in the list below «[^\p{L}\p{M}\p{Z}\p{N}]» A character with the Unicode property “letter” (any kind of letter from any language) «\p{L}» A character with the Unicode property “mark” (a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.)) «\p{M}» A character with the Unicode property “separator” (any kind of whitespace or invisible separator) «\p{Z}» A character with the Unicode property “number” (any kind of numeric character in any script) «\p{N}» Created with RegexBuddy Link to comment https://forums.phpfreaks.com/topic/237736-filtering/#findComment-1222007 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.