Extract First , Last and Middle name from a email id.
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 ?
@animesh123 wrote:
Extract First , Last and Middle name from a email id.
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.
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.
@animesh123 wrote:
Extract First , Last and Middle name from a email id.
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:
- First Name: Animesh
- Last Name: Mardi
- First Name: Jack
- Last Name: Reacher
- First Name: Michael
- Last Name: Fassbender
- First Name: Ritesh
- Last Name: Singh Sainik
Explanation:
- For animeshkumarmardi@gmail.com, we assume "Animesh" as the first name and "Mardi" as the last name.
- For jackreacher@gmail.com, we assume "Jack" as the first name and "Reacher" as the last name.
- For michaelfassbender@gmail.com, we assume "Michael" as the first name and "Fassbender" as the last name.
- For riteshsinghsainik@gmail.com, we assume "Ritesh" as the first name and "Singh Sainik" as the last name (assuming "Singh Sainik" is a compound last name).
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.
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 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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.