Home > DeveloperSection > Forums > How Do I Split A String By Capital Letter in VB.NET?
Sanjay Sharma
Sanjay Sharma

Total Post:45

Posted on    December-26-2014 10:17 PM

 .NET VB.Net  String 

 1 Reply(s)
 659  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?

David Miller

Total Post:30

Posted on    December-26-2014 10:34 PM

Try this:

Dim Input As [String] = "MoTuWed"

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

' Dows has Mo, Tu, Wed

Don't want to miss updates? Please click the below button!

Follow MindStick