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.

3
  • 1
    what language are you using the regex from Commented Nov 14, 2011 at 5:49
  • i an using this in ruby helper method Commented Nov 14, 2011 at 6:00
  • 1
    First you need to match the email address. stackoverflow.com/questions/703060/… has a regular expression that can do that Commented Nov 14, 2011 at 6:10

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.