php - Matching ONLY Numbers / Persian Characters And Latin -


i need regex code matches numbers/persian characters , latin ( a-z )

i wrote following code

preg_match("/[a-za-z\s\x{0600}-\x{06ff}0-9_\.\- ]/u",$_post['input'] )

and works fine .

but there problem, dont want input have ( @,#,!,%,$,&,* ) characters .

any ideas?

just use negative lookahead assertion in regex check there no such character. place @ beginning of regex. mean after /.

(?!.*[(@#!%$&*)]) 

for example:

preg_match("/^(?!.*[(@#!%$&*)])[a-za-z\s\x{0600}-\x{06ff}0-9_\.\- ]+$/u",$_post['input'] ) 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -