Sam OZ
asked on
Get String split
Hi experts,
I need to get a
The documentNumber is a string type variable . The typical value has actual number and the revision at the end after _ (Underscore)
A-BB-C-DD_1
A-BB-C-DD_10
Also it has to consider the possibility of a wrongly named document
WrongPattern_StillNeedtoPi ck_1
From the above 3 examples , I need to get the result as follows ( ActualName , Rev are variables of string type)
ActualName Rev
A-BB-C-DD 1
A-BB-C-DD 10
WrongPattern_StillNeedtoPi ck 1
I have some idea to do this with split function . Still looking for comprehend code
I need to get a
The documentNumber is a string type variable . The typical value has actual number and the revision at the end after _ (Underscore)
A-BB-C-DD_1
A-BB-C-DD_10
Also it has to consider the possibility of a wrongly named document
WrongPattern_StillNeedtoPi
From the above 3 examples , I need to get the result as follows ( ActualName , Rev are variables of string type)
ActualName Rev
A-BB-C-DD 1
A-BB-C-DD 10
WrongPattern_StillNeedtoPi
I have some idea to do this with split function . Still looking for comprehend code
could you please provide some patterns of wrongdocument name?
ASKER
Hi Pawan,
Wrong pattern can have _ anywhere potentially . But the the text after final _ should be taken as the Rev and rest should be taken as Document name ( as in examples of my original post)
Wrong pattern can have _ anywhere potentially . But the the text after final _ should be taken as the Rev and rest should be taken as Document name ( as in examples of my original post)
Please try..
Hope it helps !!
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim str As String = "A-BB-C-DD_10"
Dim Output As String = ""
If str.IndexOf("A-BB-C-DD_") <> -1 Then
Output = str.Substring(str.IndexOf("A-BB-C-DD_") + "A-BB-C-DD_".Length)
Else
Output = str.Substring(str.LastIndexOf("_") + 1)
End If
End Sub
Hope it helps !!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Sam,
Is this done?
Regards,
Pawan
Is this done?
Regards,
Pawan