I want to perform the following functionality :
From a given paragraph extract the given String, like
String str= "Hello this is paragraph , Ali@yahoo.com . i am entering random email here as this one AHmar@gmail.com " ;
What I have to do is to parse the whole paragraph, read the Email address, and print their server names , i have tried it using for loop with substring method , did use indexOf , but might be my logic is not that good to get it , can someone help me with it please?
You need to use Regular Expression for this case.
Try the below Regex: –
OUTPUT: –
UPDATE: –
Here’s the code with
substringandindexOf: –