Application Development and Automation 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: 
Read only

extract email id from string

purva_01
Newcomer
0 Likes
4,043

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
Read only

Sandra_Rossi
Active Contributor
3,888

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

Read only

abo
Active Contributor
0 Likes
3,888

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

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,888

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 😉

Read only

abo
Active Contributor
0 Likes
3,888

behold the power of googling 😄

Read only

Harish_Vatsa
SAP Champion
SAP Champion
3,888

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.

Read only

0 Likes
3,888

Invalid for POSIX, but fine for PCRE.

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

Read only

ameya_2023
Participant
3,888

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

Read only

0 Likes
3,888

Disclaimer: the link is an article from the author.