Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Regular expression for English characters (http://www.go4expert.com/forums/regular-expression-english-characters-t4956/)

shabbir 28Jun2007 09:52

Regular expression for English characters
 
Can anybody help me in developing the regular expression for PHP that will help me to detect if the string has any English characters. What I mean by English characters is A-Z, a-z, 0-9 and all the other symbols on keyboard + some extra ones that are used frequently. I am not very good at regular expression.

pradeep 28Jun2007 11:20

Re: Regular expression for English characters
 
Yes, sure!

Code: PHP

if(preg_match('/[a-z0-9_-]+/',$stringWhereToCheck))
  print "Has english chars";


shabbir 28Jun2007 14:37

Re: Regular expression for English characters
 
What about the
Code:

!@#$%^&*()_+<>,.?/"':;{[]}\|
as far as I can remember.

pradeep 28Jun2007 14:46

Re: Regular expression for English characters
 
Any english word must have a-z to be a valid word, special characters may or may not be there!

shabbir 28Jun2007 14:50

Re: Regular expression for English characters
 
But my concern is it can have the string as :) : ) only also.

shabbir 29Jun2007 22:31

Re: Regular expression for English characters
 
Can you tell me what are the special characters in
Code:

!@#$%^&*()_+<>,.?/"':;{[]}\|
so that I can add the backslash. As far as I can get
Code:

$ , . { [ ] } \
Am I missing something?


All times are GMT +5.5. The time now is 17:21.