1

I have this sample data

[email protected]           should output         akb ggb
[email protected]         should output         sdsd sdsd
[email protected]       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:

"[email protected]".replaceAll("@.*", "").replace(".", " "); // "akb ggb"

This will work for any number of "names", eg input of [email protected] would result is "alfred e neuman" (three words)

Bohemian
  • 412,405
  • 93
  • 575
  • 722