I have a variable temp:
String temp = "Ms Abc`<abc@gmail.com`>;Mr Cde`<cde@mail.com`>;Miss Xyz`<xyz@mail.com`>";
Now I have to split this variable temp string into an ArrayList or String[] so that I can extract title, name, emailid for insertion into a database. I’m only able to split the email id using following code:
ArrayList emailIdList = new ArrayList();
Pattern p = Pattern.compile("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b",Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(s);
while (m.find()){
emailIdList.add(m.group());
}
But I’m having a problem getting the title and name as I am stuck with the logic.
How this can be done?
I would suggest to use split multiple times and store value in collection like ArrayList.
But with this method you need to make sure that values will come in same format. Any change in format will result in failure of code or exception in your application.
I hope this helps.