on ‎2019 Feb 15 9:59 PM
Hi ,
I have an email field in one of my custom model.
I want to use the below regex pattern to be used for validating in backoffice. \\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,20}\\b
Tried to use PatternConstraint,but it was always throwing invalid email even i enter valid email.
Could some one please throw light on the same?
Request clarification before answering.
Your RegEx, \\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,20}\\b seems to invalid for email. It does not even pass an email address like a@b.com. You can check a Java RegEx using an online tool like https://www.freeformatter.com/java-regex-tester.html .
You can try a RegEx like the one given below from the link I have mentioned above:
^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.