Dim text As String = "One car red car blue car"
Dim pat As String = "(\w+)\s+(c ar)"
' Compile the regular expression.
Dim r As Regex = new Regex(pat, RegexOptions.Ig noreCase)
' Match the regular expression pattern against a text string.
Dim m As Match = r.Match(text)
Dim matchcount as Integer = 0
While (m.Success)
matchCount += 1
Console.WriteLi ne("Match" & (matchCount))
Dim i As Integer
For i = 1 to 2
Dim g as Group = m.Groups(i)
Console.WriteLi ne("Group" & i & "='" & g.ToString() & "'")
Dim cc As CaptureCollecti on = g.Captures
Dim j As Integer
For j = 0 to cc.Count - 1
Dim c As Capture = cc(j)
Console.WriteLi ne("Capture" & j & "='" & c.ToString() _
& "', Position=" & c.Index)
Next j
Next i
m = m.NextMatch()
End While
chanmm
"Ya Ya" <ra***@hotmail. com> wrote in message
news:uU******** *****@TK2MSFTNG P12.phx.gbl...
Thanks, but I am looking for example using REGEX.
ra***@hotmail.c om
"Alex Levi" <Al******@discu ssions.microsof t.com> wrote in message
news:44******** *************** ***********@mic rosoft.com... Dim txt As String
txt = "this is a fixed text THE NEEDED INFO more more fixed text"
txt = Mid(txt, 23, txt.Length - 22)
23 <- starting index
txt.Length - 22 <- size of your NEEDED INFO
"Ya Ya" wrote:
Hi,
I have a string with some fixed text and variable text.
For example: "this is a fixed text THE NEEDED INFO more more fixed
text".
How do I get the the variable text (THE NEEDED INFO) from this string ?
A simple example will help.
Thanks.
ra***@hotmail.c om