Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

extract email id from string

purva_01
Newcomer
0 Kudos
1,006

How to extract multiple EMAIL ID from text using sap abap code

Example : This is my 2 EMAIL ID ABC@gmail.com and XYZ@yahoo.co.in.please send me also on my another email ID LMN@hotmail.com.

It should extract exact email.ID without any '.' or space

output should be below

ABC@gmail.com

XYZ@yahoo.co.in

LMN@hotmail.com

8 REPLIES 8

Sandra_Rossi
Active Contributor
851

Use regular expressions, the Web is full of examples for emails.

abo
Active Contributor
0 Kudos
851

statistically speaking, most of those examples are wrong or incomplete.... but that is precisely part of the charm of regexp 😉

Sandra_Rossi
Active Contributor
0 Kudos
851

c5e08e0478aa4727abc4482f5be390b2 or it is the charm of searching, few answers wrong, one answer right, and that's it. Statistically, the answers to this question would be "most of answers would be wrong or incomplete anyway", so why asking 😉

abo
Active Contributor
0 Kudos
851

behold the power of googling 😄

Harish_Vatsa
Active Contributor
851

Dear purva_01,

Please try with the following regex:

(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b

There can be some edge-case scenarios that you might need to adjust.

0 Kudos
851

Invalid for POSIX, but fine for PCRE.

LOL about the OP test case, see "please" 😉

ameya_2023
Participant
851

Hello,

While this answer might not be what you initially hoped for, it sparked my curiosity and prompted me to test the capabilities of the Vertex AI Language Model.

Test1: In the prompt, I simply entered the same text and the model correctly identified that "please" is not part of the email address.

Test2: I altered the following text, simulating a possible variation in how someone might write email addresses in chat or email. This is an example of an edge case for testing. As LLM models can interpret natural language style of writing to a significant extent, the model was able to still identify the 3rd email ID.

If this meets your needs, consider trying this option or just explore for curiosity. Learn more here on how you can utilize this in ABAP.

Regards,

Ameya

0 Kudos
851

Disclaimer: the link is an article from the author.