Parse a string to first /

Posted on 2012-09-12
Last Modified: 2012-09-12
I have a field with values like this:


I want to get XY and ABC...anything before the first /. How can I do this ?
Question by:Camillia
    LVL 7

    Accepted Solution

    Dim str as string = "XY/12345"
    Str = str.split("/")(0)
    LVL 12

    Expert Comment

    You'll have to use a scripting language to isolate the section of the string you're after.

    Here is a example...

    Dim myString as string = <pass your string value to your variable>

    Dim myNewString as string = myString.Substring(0,patindex("/.",myString) -1)
    LVL 7

    Author Comment

    this is C# and the converted the first solution to C# but i get an error that split wants a "char" type field

    string str = "XY/12345";
    str = str.Split("/")[0];
    LVL 7

    Author Comment

    my bad. first solution worked

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now