Jack,
You can use the following to find the first blank line in a string.
Const pattern As String = "^$"
Dim ex As New Regex(pattern, RegexOptions.Multiline)
Dim input As String = "Line 1" & ControlChars.CrLf &
ControlChars.CrLf & "line 3" & ControlChars.CrLf
input = Replace(input, ControlChars.CrLf, ControlChars.Lf)
Dim match As Match = ex.Match(input)
If match.Success Then
Dim s As String = match.ToString
Dim index As Integer = match.Index
Dim header As String = input.Substring(0, index)
End If
If you don't want the Replace in there you can use:
Const pattern As String = "\r\n\r\n"
Dim ex As New Regex(pattern, RegexOptions.Multiline)
Dim input As String = "Line 1" & ControlChars.CrLf &
ControlChars.CrLf & "line 3" & ControlChars.CrLf
Dim match As Match = ex.Match(input)
If match.Success Then
Dim s As String = match.ToString
Dim index As Integer = match.Index
Dim header As String = input.Substring(0, index)
End If
The important thing is the RegexOptions.Multiline.
Hope this helps
Jay
"JackRazz" <Ja******@NotValid.com> wrote in message
news:O8*************@TK2MSFTNGP09.phx.gbl...
Anyone know the regular expression to match a blank line where the byte
sequence is "0D 0A 0D 0A"
ive tried "\r\n\r\n+", "^$+" "\n\r" with no success. Any Ideas?
Thanks - JackRazz
This is the code fragment I'm trying
Dim r As Regex, m As Match, i As Integer
Const matchBlankLine As String = "\n\r"
'Const matchBlankLine As String = "^$+"
Try
r = New Regex(matchBlankLine, reOptions)
m = r.Match(rawMsg)
If m.Success
Dim s As String = m.ToString
i = m.Index
mHeaderSection = rawMsg.Substring(0, i)
End If
Catch
MsgBox("oops")
End Try