Want a regexp in PHP (username that can be the email) that can be

In order to “say regex” much much more needs to be known.

In particular:

  • what exact conditions must always be true
  • what exact conditions must never be true
  • what conditions might be true but don’t need to be.

Conditions include:

  • what characters
  • the position of the characters
  • character groupings
  • character sequences

The more accurately and precisely you get things defined the better the chance a regex will do what you want it do.

The fiels is user name

Ok
All letters or all numbers
Must Start and end with letter or number and contains in the mid zero or one letter number or .-@.
Basically .-
@ must not be two consecutive , and @ only one

Basically
All letters or all numbers
Must/required Start and end with letter or number
Email addresses permitted… (but not Required be email) eg from social login email

Thanks. Not bad for a first start, but the contradictory conditions need to be rectified. eg.

“All letters or all numbers”
something like AhgYt or 39875 would match but not something like A9g7t

the characters .-_@ are neither letters nor numbers

"Email addresses permitted’ as felgall posted if you want to let emails be used as usernames the filter or regex in post 5 will work.

I’m guessing what you want is usernames that might be in email syntax.

But when you say “from social login email” that would mean you want usernames that are in email syntax.

This meant case all letters valid or all numbers valid since start end with letter or number

The 4 chars must not be in the start or must not be in the end and are optional

By social login get email and goes to username… if no social email like twitter login get id or username of twitter and assign to username

So for the person whose Twitter email is “@@”@[127.0.0.1] has to be able to have that stored as the username in order for them to be able to login via Twitter.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.