meto5757 Posted February 7, 2013 Share Posted February 7, 2013 Hello, I tried to change the login system for my DB to be both username and E-mail. now I have the data like : Mat:mat34@example.com Now I would like to make a reg Ex to extract only mat34. I know that explaod in php can do it , but what about RegEx ? Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted February 7, 2013 Share Posted February 7, 2013 Don't put the two pieces of data into the same column. Have one for the username and one for the email address. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 7, 2013 Share Posted February 7, 2013 If you always add a semi-colon to the username, and you don't allow it to be used in usernames, you don't need regular expressions for this. Just a simple substr () and strpos () combination. That said: Why would you store the username and e-mail combined? This goes against good database design, and as such you're only creating more work for yourself. As evidenced by this thread. I recommend storing them in two different fields, as you were. If you want to use the e-mail in addition to the username as a possible identificator when your users log in, then add an "OR" in your query. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.