c# - Chrome autofill not picked up by regex -


i doing server-side checks using asp.net c#. have spotted error within system when debugging, here code:

regex validemail = new regex("/^\\s+@\\s+\\.\\s+$/");     if (!validemail.ismatch(email_txt.text))       {             email_lbl.text = "you must enter valid email address";             email_lbl.forecolor = system.drawing.color.red;             email_txt.bordercolor = system.drawing.color.red;             email_txt.borderstyle = system.web.ui.webcontrols.borderstyle.solid;       }       else       {        } 

this within button click event.

the issue is, when autofill form selecting email address dropdown list of textbox supplied google chromes autofill "liverpool@live.com" falls if statement rather else statement.

however, if manually fill out email address exact same fall else statement.

does know problem why happening?

no delimiters allowed in c# regex pattern.

use new regex(@"^\s+@\s+\.\s+$").

see demo

sample code:

var rx = new regex(@"^\s+@\s+\.\s+$"); console.writeline(rx.ismatch("liverpool@live.com")); 

note @"" verbatim string literal convenient notation use when writing c# regex patterns. not have escape anything, double " (as "") match 1 ".


Comments