Friday, 12 May 2017

Regex to extract login username

Currently, I had one Web chat project, I use socket.io to send and receive messages real time. I need to get the login if user types.

I try to use regex but I'm a beginner within and the format can be multiples like:

  • My login is sayuri.mizuguchi
  • My login? So, sayuri.mizuguchi Okay?

The format from login is always firstname.lastname

In this case, all messages stay inside a parameter and this data is saved inside one variable but I really try use multiples regex for test and anything works. Someone can help me, please?

Example:

console.log(data.usertyped); // My login is sayuri.mizuguchi

I need use like condition, like: input.text.find('\d{11}') that get 11 numbers inside one condition and I need the same to get login.

Thanks advance.



via Sayuri Mizuguchi

No comments:

Post a Comment