You guys can also consider parsing a string, like user@company.com, or "user @domain".
This is what I am doing now:
If the string contains '\', divide the string by '\' and extract the username and domain
Else If the string contains "@", divide the string by "@" and extract the username and domain
Else treat string as username without domain
I'm still looking for a better solution when the input string is not in an easily predicted format, that is, "domain \ user @domain". I think RegEx ...
Update: I am standing fixed. My answer is a bit out of context, it refers to the general case of analyzing a username and domains outside of user input, for example, at a user / login prompt. Hope this still helps someone.
Omar Feb 01 '10 at 10:06
source share