Avatar of Chris Jones
Chris Jones
Flag 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

Visual Basic.NET.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
Chris Jones

8/22/2022 - Mon
Ken Butters

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
Jorge Paulino

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

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

Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Ken Butters

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Chris Jones

ASKER
oh LOL :) oops let me try
Chris Jones

ASKER
ok its working .....
Ken Butters

Good! :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Chris Jones

ASKER
Thanks that is a lot faster than the regex.
Chris Jones

ASKER
great help