Hi Lisa,
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to use a regular
expression to exact a matched string from a long string.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
I think you may try to use the group to do the job.
Imports System.Text.RegularExpressions
Module Module2
Public Sub Main()
Dim Text As String = "2004-04-12 09:31 by <a class=link
href=""javascript
:jsOpen fsafsadfs"
System.Console.WriteLine("text=[" & Text & "]")
Dim r As Regex = New
Regex("^(?<MatchedStringName>\d\d\d\d-\d\d-\d\d\s\d\d:\d\d\sby\s<a
class=link href=""javascript
:jsOpen)(.*)", RegexOptions.IgnoreCase)
Dim mt As Match = r.Match(Text)
Console.WriteLine(mt.Groups("MatchedStringName").ToString())
'The Line will print out 2004-04-12 09:31 by <a class=link
href="javascript
:jsOpen
End Sub
End Module
For detailed information about group and regular expression, you may take a
look at the link below.
Grouping Constructs
http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/cpcongroupingconstructs.asp
Regular Expression Language Elements
http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/cpconregularexpressionslanguageelements.asp
Please apply my suggestion above and let me know if it helps resolve your
problem.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.