regex pattern question
in
Programming Questions
•
1 year ago
I need to have the names separate from the emails.
The email isn't always surrounded by a < and >, neither there is always a name.
However, the 'groups' (email + optional name) are always separated with a comma.
Only there are also name's that have a comma in them like "
in other words, from the test string i want to replace the comma's marked here:
"Talboom , Esther" < E.Talboom@wegener.nl>,
"Wolde , Jos van der" < J.vdWolde@wegener.nl>
my non working attempt
The email isn't always surrounded by a < and >, neither there is always a name.
However, the 'groups' (email + optional name) are always separated with a comma.
Only there are also name's that have a comma in them like "
Talboom, Esther" ,
so first i want to replace the comma that is surrounded by the double quote character -> " , after that i can split.
in other words, from the test string i want to replace the comma's marked here:
"Talboom , Esther" < E.Talboom@wegener.nl>,
"Wolde , Jos van der" < J.vdWolde@wegener.nl>
my non working attempt
- String test = "\"Talboom, Esther\" <E.Talboom@wegener.nl>, DRP - Wouter Haan <wouter@drp.eu>, \"Wolde, Jos van der\" <J.vdWolde@wegener.nl>, \"Debbie Derksen\" <deberken@casema.nl>, corine <corine5@xs4all.nl>, clankilllller@gmail.com, \"Markies Aart\" <A.Markies@wegenernieuwsmedia.nl>";
- Pattern p = Pattern.compile("\".*,.*\"[^<]");
- Matcher m = p.matcher(test);
- while(m.find()) {
- println(m.group(0));
- }
1