How to match multiple lines with Regex in C#?

Posted by Emanuel on Stack Overflow See other posts from Stack Overflow or by Emanuel
Published on 2010-04-14T21:37:51Z Indexed on 2010/04/14 21:43 UTC
Read the original article Hit count: 278

Filed under:
|
|
|

I have the following text:

--------------030805090908050805080502
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: <[email protected]>

/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAA
/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAA
QBQH/9k=
--------------030805090908050805080502
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: <[email protected]>

/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAA
/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAA
juu41lRHFLufPCAID//Z
--------------030805090908050805080502--

And I need to get with Regex in C# 2 parts:

  1. between the first and the second occurence of the string "--------------030805090908050805080502"
  2. between the strings "--------------030805090908050805080502" and "--------------030805090908050805080502--"

I tried this regex:

--------------030805090908050805080502(\r.*)*--------------030805090908050805080502

but in C# regex.Matches(...) return only "--------------030805090908050805080502".

Any idee?

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex