How do I achieve the following with a regex:
- Match if string doesn't start with a certain character
- Match if there are no two ","'s or any other characters
- Match if the string has double ", even if they are not adjacent
Using Python.
Currently I am attempting to match email addresses with these rules included. The current pattern I have is
pattern = '^([A-Z0-9._-\"]|\"[!\,;]\"){1-127}+@[^-][A-Z0-9.-]{3-256}+\.[A-Z]{2,4}[^-]$'
But I am confused with how to implement these rules.
Being more specific: I want a pattern that matches an email adress consisting of 2 parts (name, domain). The name part should be no longer then 128 characters and should go before @. It should cosist of a-z0-9 chracters and also ., _, -, ". The name can't have to adjacent dots. If the name has " then it should be paired with another ". The name can have !;, characters if they are in between paired ".
The domain name should be no longer then 256 and no shorter then 3 characters, should be separated by a dot. The domain name can't begin or end with -.
This information is given to help you understand what I want, the main question is about three rules I stated in the top. I will gladly appreciate it if you tell me how to achieve them.