php - Regex issue unicode chars, is it safe to parse a Post to preg_match? -
im trying thing working accept unicode letters, can cover languages urdu , other special letters around world.
tried :
/^[\p{l}\p{zs}\p{n}]+$/uix
but gets me no heck doing wrong? tried of regex tools , cant work in way.
got working found out htmlentities messing result safe use $_post preg_match ?
!preg_match("/^[\\p{l}\\p{zs}\\p{n}\\p{m}]+$/u", $_post['firstname'])
you can use
'/^[\p{l}\p{m}\p{zs}\p{n}]+$/u'
note urdu , lot of other languages have diacritics , \p{m}
matches them.
you not need double backslash when using single quoted literal.
with post, seems need make sure value set , use string.
if ( isset( $_post[ 'firstname' ] ) ) { $name = strip_tags( trim( $_post[ 'firstname' ] ) ); }
see this article.
Comments
Post a Comment