Parsing POP3 'LIST' output

  • Thread starter Thread starter aleko.petkov
  • Start date Start date
A

aleko.petkov

Hi

I am trying to get the message IDs returned by the LIST command into a
string list.
For example, given the following input string:

+OK 5 Messages( 4099 octets )
1 9163
2 6962
3 8953

produce { "9163", "6969", "8953" }.

using the following code:

string[] msgIDs = Regex.Split( response, @"\d+ (\d+)",
RegexOptions.Singleline );


This sort of works, except that the resulting array includes
non-matches as well. Is it possible to return only the group values
this way, or do I have to fiddle with MatchCollections, and Groups?

Thanks,

Aleko
 
Hi

I am trying to get the message IDs returned by the LIST command into a
string list.
For example, given the following input string:

+OK 5 Messages( 4099 octets )
1 9163
2 6962
3 8953

produce { "9163", "6969", "8953" }.

using the following code:

string[] msgIDs = Regex.Split( response, @"\d+ (\d+)",
RegexOptions.Singleline );


This sort of works, except that the resulting array includes
non-matches as well. Is it possible to return only the group values
this way, or do I have to fiddle with MatchCollections, and Groups?

Possibly enough to change your match pattern to

^\d+ (\d+)$

so only lines which *only* contain number-space-number will match
 
Back
Top