Click here to Skip to main content
15,917,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a problem and I would be very grateful if you help me.

In the picture below we have a string, containing everything from "batch" to "booked out by moraru vladut" is a String. Of this I want to remove only the amount circled in red. I do not know after take, to make split after "/" can be found or otherwise?

The last "/" of the show before I circled differentiated, but can contain two "/"

http://postimg.org/image/onmt8es2l/full/[^]

Thanks a lot!
Posted

Below code should work:
VB
Dim temp As String = "batch 235/689/45 pct booked out"
temp = temp.Substring(temp.LastIndexOf("/"C) + 1)
Dim lastValue As String = temp.Split(" "C)(0).ToString()
 
Share this answer
 
Comments
MoraruVladut 15-Oct-15 2:26am    
Sorry i have String like that and i need to display : 235/689, 45 is pcs, and 235/689 is the batch


Dim temp As String = "Batch 235/689/45 pcs booked out by vladut moraru on 10/15/2015"
temp = temp.Substring(temp.LastIndexOf("/"C) + 1)
Dim lastValue As String = temp.Split(" "C)(0).ToString()

Sorry, i explane you wrong
[no name] 15-Oct-15 2:34am    
As per your image there is always "/" and that should be unique otherwise how you will fetch part of your string.

I am not sure you are adding one more type text after providing the answers. If you have different types of text then implement your custom logic.
MoraruVladut 15-Oct-15 2:43am    
I explane here, step by step : http://www.codeproject.com/Questions/1039834/How-do-I-know-which-are-the-first-characters-befor

Thanks a lot
VB
Dim str As String = "235689/45"
Dim digit As Integer = Integer.Parse(str.Split("/"C)(1).ToString())

Hope you wanted this :)

-KR
 
Share this answer
 
Comments
MoraruVladut 15-Oct-15 1:22am    
Ies but if i have like that

Dim str as String = "batch 235/689/45 pct booked out"

How i find 45?
Krunal Rohit 15-Oct-15 2:51am    
var d = Regex.Match(str, @"\d+").Value;

will give you the number.

-KR
I have Solution here:

VB
Dim regExMatch2 As System.Text.RegularExpressions.Match
                           regExMatch = System.Text.RegularExpressions.Regex.Match(CheckIfBooked, "Batch (.+)/\d+ pcs", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
                           regExMatch2 = System.Text.RegularExpressions.Regex.Match(CheckIfBooked, "Batch (.+)/(\d+) pcs", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
                           If regExMatch.Success Then
                               batch = regExMatch.Groups(1).Value
                           End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900