Posts filed under 'jscript'

Regular expression & jscript problem

Few days ago when i was trying to validate a PHP page with javascript, i found something interesting. i like to share with u.

i was trying to validate a email id. for that, i write my own regular expression. i tried lots of combination’s of regular expression. but still it was not working. i wasted to much time on it !! lots of work to do. got worried !! why it was not working, though all the expressions were perfectly ok !! why!!

following are those expression:

  • var email_regExp="^[A-Z0-9._]+@[A-Z0-9.-]+.[A-Z]{2,6}$";
  • var exEmailAdres="^([ tnrfv]*)([a-z]{1})[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+[.]([a-z]{2,4})([ tnrfv]*)$";
  • var exEmailAdres="/w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*$/";
  • var email_regExp="^[a-zA-Z][w.-]*[a-zA-Z0-9]+@[a-zA-Z0-9][w.-]*[a-zA-Z0-9].[a-zA-Z][a-zA-Z.]*[a-zA-Z]$";


now i solve it. can anyone tell me what was my fault ?!?

well the answer is i used double quote( ” ) instate of single quote( ‘ ). thats why it was not working.

var email_regExp='^[a-zA-Z][w.-]*[a-zA-Z0-9]+@[a-zA-Z0-9][w.-]*[a-zA-Z0-9].[a-zA-Z][a-zA-Z.]*[a-zA-Z]$';

REASON: When, i use double quote( ” ), the php parser can’t figure out the ‘@’ sign. and it try to do some action for this “@”. thats why the whole expression is not working.  So, when its about to get a string value,its better to use single quote( ‘ ) instate of double quote( ” ).

6 comments August 14, 2008


My Profile


# Software Eng. # Worked with C,C++, JAVA and PHP. #Love to play with codes. # Mostly like to do programming with 'C'. # I am not a CODER, but a DEVELOPER.

Admin Panel..

Life Cycle

November 2009
S S M T W T F
« Sep    
 123456
78910111213
14151617181920
21222324252627
282930  

Clouds

cakephp codeIgniter desktop htaccess jscript linux mixed my words php regular expression

Just Posted

TOP R@TED

TaGs

cakephp codeIgniter desktop GP htaccess image upload installation jscript linux news password Personal Life php regular_Xpression script session validation

Archives

Top Posts

CoMmEnTs

Blog Stats

My Web Links

Web Links

RSS Xperts.PHP