|
-
Dec 27th, 2019, 10:55 PM
#1
Thread Starter
New Member
[RESOLVED] How can I split a string and get the value of the entire other side?
I have a string in the application, the strings contents are "value1 | value2".
I've been using this code to split it using spaces and to the 2nd so I get value 2 (that may have been worded weird sorry):
Code:
Dim sString As String = "value1 | value2"
Dim split As String = sString.Split(" ")(2)
The problem with this is, I've realized most of the value2 values will have multiple spaces and things for that side of the value. How should I go about getting the right sides contents even with multiple spaces?
Edit: Fixed I just used sString.Split("|")(1)
Last edited by ExoTiic; Dec 27th, 2019 at 11:08 PM.
-
Dec 27th, 2019, 11:06 PM
#2
Re: How can I split a string and get the value of the entire other side?
If there is always a "|" separating the values, use "|" as the Split character.
Note: Based on your example there will be a leading space in the second value (and a trailing space in the first value for what its worth) that you will need trim off the front if that space causes you an issue.
-
Dec 28th, 2019, 07:26 PM
#3
Re: [RESOLVED] How can I split a string and get the value of the entire other side?
Use sString.Split(New String() {“ | “}, StringSplitOptions.None)
To get the last element, use the LINQ .Last function
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|