Link to home
Start Free TrialLog in
Avatar of Chris Jones
Chris JonesFlag for United States of America

asked on

i need a reg ex in vb.net

Hello,

i have this regex function but its not working like i need it to,

i have a string that i need to split only on , nothing else and its spliting all of my special caracters such as  -  and spaces.


here is what my function does
     Private Function SplitWords(ByVal s As String) As String()
        Return Regex.Split(s, "\W+")
    End Function

Open in new window

Avatar of Ken Butters
Ken Butters
Flag of United States of America image

you can use VB built in split function for that:

Private Function SplitWords(ByVal s As String) As String()
        Return s.Split(New Char(){"."c})
End Function
You want to split by "," ?

Why don't do:

    Private Function SplitWords(ByVal s As String) As String()
        Return s.Split(","c)
    End Function

Open in new window

Avatar of Chris Jones

ASKER

is there a way  i can split with regex my code is treating the vb. split like a large string and not spliting the strings here is what i am trying to do .

       Dim Accounts As String() = SplitWords(txtRoot.Text)
        ' Use For Each loop over words and display them
        Dim List As String
        For Each List In Accounts
            If List = "" Then
            Else
                'Call Create_Folder(folder, List)
                Stat.Items.Add(Create_Folder(folder, List))
            End If
        Next

Open in new window


and the function
Private Function SplitWords(ByVal s As String) As String()
        Return s.Split(New Char(){"."c})
End Function [code]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh LOL :) oops let me try
ok its working .....
Good! :)
Thanks that is a lot faster than the regex.
great help