How Do I Split A String By Capital Letter in VB.NET?

Total Post:45

 1537  View(s)
Rate this:
Im working on web services made in VB.NET Im merging datasets and datatables from multiple web services into 1 dataset. Im changing the format of some of the data, for example my web service lists the days of the week as a boolean but other web services are using a string like MoTuWedTh... Im on a webservice now where they have used MoTuWeTh.... on some and MoTuWedTh... on others. I was splitting the string into a char array and looping through it and using a if statement to say if char(0) & char(1) or char(2) & char(3)... = Mo then Monday column(which is a boolean) = true.

This was working well until I got to this webservice, if I look for wednesday as We then the days afterthat are not recognised because thursday would become dT, friday would be hF etc.

My question is, how can i get the MoTuWed... string to split at each capital letter so it becomes Mo Tu Wed...

Or can you thing of another way I can do this?
  1. Post:30

    Re: How Do I Split A String By Capital Letter in VB.NET?

    Try this:

    Dim Input As [String] = "MoTuWed"

    Dim Dows As MatchCollection = Regex.Matches(Input, "[A-Z][a-z]+")

    ' Dows has Mo, Tu, Wed