Question posted on Stackoverflow.com: http://stackoverflow.com/questions/1153630/extract-all-characters-after-last-occurrence-of-a-pattern-c
Hello,
The strings are of the following pattern
1.0.0.0 1.0.0.1 1.0.0.2 ... ... ...
I am looking for a code which will read the last created string and increment the last numeral by 1 and save it as a new string.
How do I do it?
Best Regards,
Magic
---
My response:
Imports System.Text.RegularExpressions
Module Module1
Sub Main()
Dim matchC As
MatchCollection = Regex.Matches("111.222.333", "\d+")
Dim i As Integer = 1
For Each x In matchC
Console.Write(i.ToString & " ")
Console.WriteLine(x)
i = i + 1
Next
' remember to check to make sure case no matches occur in your real code.
Console.WriteLine("last number is " & matchC.Item(matchC.Count - 1).ToString)
Console.ReadLine()
End Sub
End Module
Useful reference: http://msdn.microsoft.com/en-us/library/ms972966.aspx
Regular Expressions in ASP.NET
Monday, July 20, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment