Monday, July 20, 2009

Extracting all Characters after last occurrence of a pattern C#

Question posted on


The strings are of the following pattern ... ... ...

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,



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 & " ")
i = i + 1

' 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)
End Sub
End Module

Useful reference:
Regular Expressions in ASP.NET

No comments:

Post a Comment