I'm not a regexp person (wish I was though), and I'm hoping someone can give
me a hand here.  Consider the following strings:


-          domain\usern...@example.org

-          domain\username

-          the same as above but with / instead of \  (hey, it happens)

-          usern...@example.org

-          username


Essentially I have a sign-up form where folks will be typing in their
username.  The problem is, in our organization, when you tell someone to
enter their username, it could end up being any of the above examples
because they're used to a domain log in procedure where in some cases they
type the whole thing, in other cases just the e-mail, or sometimes just the


So what I'd like is a way to capture just the 'username' part, regardless of
what other pieces they put in.  In the past I would write a rather
inefficient split() routine and eventually get what I need.  With split()
getting deprecated, I figured I may as well start looking into how to do it
properly.  There's preg_split(), str_split(), explode() . possibly others.


So, what's the proper way to do this?  How can I capture just the part I
need, regardless of how they typed it in?





Reply via email to