Home All Groups Group Topic Archive Search About

Parsing POP3 'LIST' output

Author
9 Jun 2006 2:35 AM
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

Author
9 Jun 2006 9:15 AM
Larry Lard
aleko.pet***@gmail.com wrote:
Show quote
> 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

--
Larry Lard
Replies to group please

AddThis Social Bookmark Button