1

I have this sample data

akb.ggb@yahoo.com           should output         akb ggb
sdsd.sdsd@gmail.com         should output         sdsd sdsd
asdasd.asasd@tmail.com       should output        asdasd asasd

I need a regexp to find fullname from email like above.

Any help should be appreciated.

parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85
fff
  • 21
  • 3

2 Answers2

2

^[^@]* will output akb.ggb
you will then need to split by the '.' character...

the regex syntax is obviously programming language dependent.

^([^\.@]+)\.*([^@]*) will in both ruby and java place in group-1 (capture-1) the first name, and in group-2 (capture-2) the surname (if it exists).

You can play with regex online:
Ruby
Java

Ofir Farchy
  • 7,657
  • 7
  • 38
  • 58
1

You haven't told us your language, but in java, it would look like:

"akb.ggb@xyx.com".replaceAll("@.*", "").replace(".", " "); // "akb ggb"

This will work for any number of "names", eg input of alfred.e.neuman@mad.com would result is "alfred e neuman" (three words)

Bohemian
  • 412,405
  • 93
  • 575
  • 722