Split a string to array

I have a string and I want to split… Please help me.

My data = “alok”,“Deepak,good,boy”,“ram”
I want to split like =
alok
Deepak,good,boy
ram

Hi,

Can you try the following expression?

stringArray = System.Text.RegularExpressions.Regex.Matches(yourString,"""(.*?)""").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Groups(1).Value).ToArray

Regards,

1 Like

Thank you sir… Solved…

1 Like

hi couldd you explain this regex to improve knowledge what is cast …

Hi,

System.Text.RegularExpressions.Regex.Matches returns MatchCollection class. As we cannot use LINQ for this class directly, it’s translated to IEnumerable<Match> using the Cast method, then use LINQ.

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.