I'm trying to write an email validation program, and I'm having a lot of trouble finding a way to check a string for invalid consecutive chars. Specifically, emails cannot have a repeated ".", "-", or combination of these two chars, so email-.@abc.com is invalid.
Does anyone have any ideas on how I could approach this? In particular, the "-." and ".-" possibilities are messing me up.
Read the string one character at a time. Compare the current character to the next character until you find an invalid match or you run out of characters.
Thanks a lot guys. I tried to do the first way but I'm retarded so I couldn't figure it out without making a huge nested for/if loop, so I'll probably have to stick with the second way and hope my professor finds it acceptable.
Bookmarks