2023 Dec 28 11:14 AM
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
2023 Dec 28 11:46 AM
Use regular expressions, the Web is full of examples for emails.
2023 Dec 28 4:04 PM
statistically speaking, most of those examples are wrong or incomplete.... but that is precisely part of the charm of regexp 😉
2023 Dec 28 5:16 PM
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 😉
2023 Dec 28 5:47 PM
2023 Dec 28 5:53 PM
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.
2023 Dec 28 6:23 PM
Invalid for POSIX, but fine for PCRE.
LOL about the OP test case, see "please" 😉
2023 Dec 31 8:52 AM
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
2023 Dec 31 9:45 AM