[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

Parse a string to first /

I have a field with values like this:

XY/12345
ABC/mm1888

I want to get XY and ABC...anything before the first /. How can I do this ?
0
Camillia
Asked:
Camillia
  • 2
1 Solution
 
Padre_CorleoneCommented:
Dim str as string = "XY/12345"
Str = str.split("/")(0)
0
 
Jared_SCommented:
You'll have to use a scripting language to isolate the section of the string you're after.

Here is a vb.net example...

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

Dim myNewString as string = myString.Substring(0,patindex("/.",myString) -1)
0
 
CamilliaAuthor Commented:
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];
0
 
CamilliaAuthor Commented:
my bad. first solution worked
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now