0

I have been working on splitting emails which in turn seperated by commas. For example, consider below three emails:

"my@.>,"<xyz@abc.com>,mine@abc.com,"my,s"elf"<pqr@abc.com>,"myself"<lmn@abc.com>

The result of splitting should be like:

1) "my@.>,"<xyz@abc.com>
2) "my,s"elf"<pqr@abc.com>
3) "myself"<lmn@abc.com>
4) mine@abc.com

I have tried using split() in java but there were commas(,) in sender name which makes the splitting process tedious. Is there any way to combine those emails in java?

Note: The emails can also contain quotes( " ) in sender name as well.

Ahamed Yasir
  • 189
  • 1
  • 13
  • 2
    your string is not in proper format – Ryuzaki L Jul 23 '19 at 12:35
  • can you please why it is not in proper format. If you confuse between quotes then the quotes were escaped properly – Ahamed Yasir Jul 23 '19 at 12:46
  • Based on valid email address format – Ahamed Yasir Jul 23 '19 at 12:48
  • Also I think this is not a duplicate question as the related question involves only commas in between quotes. – Ahamed Yasir Jul 23 '19 at 12:49
  • Is it a real life case ? Will we have comma in person names ? If reallly happens, since it is quite strange kind of data, i think may be u can split based on `>,` or even `.com>,` and then add `>` or `.com>` at the end of the string – Abbin Varghese Jul 23 '19 at 12:56
  • Your string is a mess, are you getting it from an external program/data source or are you generating them? – Felype Jul 23 '19 at 13:00
  • Here, with this expression you should be able to get going somewhere: https://regex101.com/r/ahHA2K/1 Of course if your data has even more irregularities in its formatting it's going to require further treatment. – Felype Jul 23 '19 at 13:10

0 Answers0