Results 1 to 3 of 3

Thread: Problem with System.Text.RegularExpressions.Regex.Split [Resolved]

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163

    Question Problem with System.Text.RegularExpressions.Regex.Split [Resolved]

    I want to split a string:
    C:\Documents and Settings\Tan\My Documents\Trainee\Payroll System\bin
    This is the code i had written:
    Code:
    Dim strSplitted() As String = System.Text.RegularExpressions.Regex.Split(strFileName, "\")
    But an error occurs with this error message:
    An unhandled exception of type 'System.ArgumentException' occurred in system.dll

    Additional information: parsing "\" - Illegal \ at end of pattern
    How can i split it?
    Please guide, thank you.
    Last edited by albertlse; Aug 21st, 2003 at 08:10 PM.

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    VB Code:
    1. [color=blue]Dim[/color] strFileName [color=blue]As String[/color] = "C:\Documents and Settings\Tan\My Documents\Trainee\Payroll System\bin"
    2.         [color=blue]Dim[/color] strSplitted() [color=blue]As String[/color] = strFileName.Split("\")
    3.         [color=blue]Dim[/color] x [color=blue]As Integer[/color]
    4.  
    5.         [color=blue]For[/color] x = [color=blue]LBound[/color](strSplitted) [color=blue]To UBound[/color](strSplitted)
    6.             MessageBox.Show(strSplitted(x))
    7.         [color=blue]Next[/color]

    or ...
    VB Code:
    1. [color=blue]Dim[/color] strSplitted() [color=blue]As String[/color] = "C:\Documents and Settings\Tan\My Documents\Trainee\Payroll System\bin".Split("\")
    2.         [color=blue]Dim[/color] x [color=blue]As Integer[/color]
    3.  
    4.         [color=blue]For[/color] x = [color=blue]LBound[/color](strSplitted) [color=blue]To UBound[/color](strSplitted)
    5.             MessageBox.Show(strSplitted(x))
    6.         [color=blue]Next[/color]
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163

    Thumbs up

    it's working fine now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width