0

How can I remove illegal chars from multilanguage string, such as <>'"?* etc.?

I can't just use

$allow = "/[^abcdefghijklmnopqrstuvwxyz0123456789-]+/";
$q = preg_replace($allow, "", $q);

I need this to use on a full name field with multilanguage support.

  • 2
    simply, its their name, let them type anything they want - it will do NO harm –  Sep 30 '14 at 23:54
  • 2
    a usefull read: http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ –  Sep 30 '14 at 23:55
  • Fun read :) Maybe you are right it's 3am shouldn't be coding now... – user3841653 Sep 30 '14 at 23:58
  • 2
    programmers tend to be control freaks. –  Oct 01 '14 at 00:01
  • Your notion of "illegal character" is very naive and broad: are characters like `œ` or `é` allowed? And what is your general goal, why are you trying to forbid characters? – Casimir et Hippolyte Oct 01 '14 at 01:10
  • he or she seems to be wanting to exclude non alphabetical characters (<>'"?* are not likely to appear in names in any language). does php have a unicode alphabetic character class? – 1010 Oct 01 '14 at 03:37
  • remember little Bobby tables http://xkcd.com/327/ – 1010 Oct 01 '14 at 03:53
  • @1010: That shouldn't even be a problem when you use prepare statement. It's generally a warning against string concatenation and poor input sanitization when building an SQL query. – nhahtdh Oct 01 '14 at 05:04
  • @CasimiretHippolyte so names are really names and not like ahm@t, X's pet, "Mike N.", ........ œ or é etc. of course allowed – user3841653 Oct 01 '14 at 09:46
  • I think here you'll find what you want: http://stackoverflow.com/questions/5963228/regex-for-names-with-special-characters-unicode. however beware that X's pet could be a name in some language you don't know... – 1010 Oct 03 '14 at 03:10

0 Answers0