javascript - Regex validation in java and java scipt for email address -


We java ^ [\\ w! # \\ $] in order to validate the email address below the regular expression. \\ * \\ + = \\ \\ ^ \\ / _ ~ -.!?] (\\ [\\ w # \\ $ '\\ * \\ + = \\ \\ ^ \\ / _ ~ -] +) * @ ([a-zA-Z0-9 \\ -] + \\.) + [AG] {2,4} $ and it worked fine with an invalid email address < Code> raju.rathi@gmail.com& ^ (* And * (* 2 * ) But when I use the same regular expression in JavaScript, it does not work and fails even with valid email addresses. What is the root cause of this mismatch For example, in javascript, I am assuming incorrect with the test condition below -

/ ^ [\ w ## '\ * * + = \ \ ^ \ / ~ -?] + (\ [\ W # \ $.! '\ * \ = = \ \ ^ \ / ~ -]) * @ ([A- ZA-Z0-9 \ -] +.. + [AG] {2,4} $ / trial ("Raju.Rathi@gmail.com")

W = # $ '* + =? ^ \ / ~ -] + (\. [\ W! # $' * + =? ^ \ / ~ -]) * @ ([one-zA-Z0-9 -] \) + [AZ.] {2,4} $ / i.test ("raju.rathi@gmail.com")

In addition to many special regex characters such as $ , + , * etc are not required to be avoided inside the character class so I have removed the unnecessary escape from your class.


Comments