BookmarkSubscribeRSS Feed
animesh123
Obsidian | Level 7

Extract First , Last and Middle name from a email id.

animeshkumarmardi@gmail.com

jackreacher@gmail.com

michaelfassbender@gmail.com

riteshsinghsainik@gmail.com

 

if no middle name the output will be blank

E.G-

First Name- Animesh , Jack 

Middle Name- Kumar ,

Last Name- Mardi , Reacher

can we use scan function too on this ?

 

 

3 REPLIES 3
ballardw
Super User

@animesh123 wrote:

Extract First , Last and Middle name from a email id.

animeshkumarmardi@gmail.com

jackreacher@gmail.com

michaelfassbender@gmail.com

riteshsinghsainik@gmail.com

can we use scan function too on this ?

 

 


NO. SCAN function would require one or more delimiter characters to separate the pieces such as the period in John.Smith@something.com

 

With your examples including multiple sources guessing any rules for name pieces is going to be difficult at best.

Reeza
Super User

I don't think you can use traditional programming here. If you're using an LLM (OpenAI or a self served model) you'll have better luck. 

Pasting your question into ChatGPT shows responses which seem reasonable.

 

 

Spoiler

@animesh123 wrote:

Extract First , Last and Middle name from a email id.

animeshkumarmardi@gmail.com

jackreacher@gmail.com

michaelfassbender@gmail.com

riteshsinghsainik@gmail.com

 

if no middle name the output will be blank

E.G-

First Name- Animesh , Jack 

Middle Name- Kumar ,

Last Name- Mardi , Reacher

can we use scan function too on this ?

 

 


 

ChatGPT response:

Extracting the first, last, and middle name from an email ID is not straightforward because email IDs typically do not directly provide such information. However, if we make some assumptions based on common patterns in email IDs, we can attempt to extract the first and last names. Middle names are not typically included in email IDs, so we won't attempt to extract them.

Here's how we can approximate the first and last names from the given email IDs:

  1. animeshkumarmardi@gmail.com

    • First Name: Animesh
    • Last Name: Mardi
  2. jackreacher@gmail.com

    • First Name: Jack
    • Last Name: Reacher
  3. michaelfassbender@gmail.com

    • First Name: Michael
    • Last Name: Fassbender
  4. riteshsinghsainik@gmail.com

    • First Name: Ritesh
    • Last Name: Singh Sainik

Explanation:

These assumptions are based on common naming conventions found in email IDs, but they may not always be accurate or applicable universally. Email IDs are generally not designed to provide structured names in a way that software can reliably parse first and last names without additional context or user input.

 

Kurt_Bremser
Super User

In plain language, write down a set of rules that solves all your cases, without producing false results.

If you can do that, someone can translate it to code.

But I can give quickly give you examples that show that your task is impossible, like

annemariemaier@mail.com

Is it Annemarie Maier, or Anne Marie Maier? Both are valid in German. In English, think of Emmy Lou vs. Emmylou.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 249 views
  • 3 likes
  • 4 in conversation