0

Have come up with the following Finite State Machine for validating an email based on the following pattern. Is this valid to be able to validate an emailaddress format (more specifically, is the FSM a correct translation of the regex below)?

enter image description here

Further, even when valid, the stages S4 and S5 can be removed (repeating states) and instead S1 can be an accepting state?

Email address format example: abc23ss@1domain.ext

Regex as a base for drawing the FSM: [a-z0-9]+@[a-z0-9]+\.[a-z0-9]+

iCrus
  • 1,210
  • 16
  • 30
  • possible duplicate of [Using a regular expression to validate an email address](http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address) – Fred Foo Jan 15 '14 at 10:17
  • Oh and no, this will not match my email address. It has a period before the @. In times gone by, it even had two periods in the domain part. – Fred Foo Jan 15 '14 at 10:18
  • 2
    Are you asking if this regexp is correct for validating email, or are you asking if the FSM is a correct translation of the regexp you gave? – Barmar Jan 15 '14 at 10:18
  • Why do you need to create your own FSM? If you use a regexp engine it will do that for you. – Barmar Jan 15 '14 at 10:20
  • @Barmar Updated the question to be more clear. I am asking if the FSM is a correct translation of the regex i gave. Also, I am trying to gain more understanding of the FSMs and hence creating on my own. – iCrus Jan 15 '14 at 10:49
  • Maybe this question is more appropriate for cs.stackexchange.com. – Barmar Jan 15 '14 at 10:53
  • @Barmar Yes, that does seems more appropriate and I should have posted there. – iCrus Jan 15 '14 at 10:57
  • 3
    This question appears to be off-topic because it is more appropriate for cs.stackexchange.com – Barmar Jan 15 '14 at 11:00
  • `abc@com` is a valid email address, see: http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses – Toto Jan 15 '14 at 11:02

1 Answers1

1

I guess it's not a bad starting point, but it's not quite there yet, and you will have to revise your FSM quite a bit. For example, the following email address would be invalid according to your FSM:

some-thing.someone@somewhere.co.uk
  • Agreed, it does not handle all possible email addressess but was looking for the confirmation of this 'first draft'. – iCrus Jan 15 '14 at 10:52