Page 1 of 1

Error: Non-ECMAScript regexes are not currently supported.

Posted: Tue Apr 25, 2017 4:24 am
by sd1388
Hi Team,

while migrating below code, I got error - Error: Non-ECMAScript regexes are not currently supported. in Java script.

Code: Select all

 string patternLenient = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                System.Text.RegularExpressions.Regex reLenient = new System.Text.RegularExpressions.Regex(patternLenient);

                //Validate Emailid
                if (!reLenient.IsMatch(TxtEmail.Text.Trim()))
                {
                    // code
                }


Is it known issue?
If yes, is there alternatives to validate email.

Thanks.

Re: Error: Non-ECMAScript regexes are not currently supported.

Posted: Tue Apr 25, 2017 4:53 am
by JS-Support @Userware
Hi,

Please use the code below to validate the email:

Code: Select all

private void ButtonCheckIfEmailAddressIsValid_Click(object sender, RoutedEventArgs e)
{
    if (Regex.IsMatch(TextBoxEmailAddress.Text, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
        MessageBox.Show(TextBoxEmailAddress.Text + " is a valid email address.");
    else
        MessageBox.Show(TextBoxEmailAddress.Text + " is NOT a valid email address.");
}


PS: you can find a CSHTML5-based Regular Expressions "Playground" in the "Other" section of the Showcase app at:
http://cshtml5.com/samples/showcase/index.html?20170308

Thanks.
Regards,
JS-Support