Solved

Get String split

Posted on 2016-11-20
5
32 Views
Last Modified: 2016-11-24
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_StillNeedtoPick_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_StillNeedtoPick                 1

      I have some idea to do this with  split function . Still looking for comprehend code
0
Comment
Question by:Sam OZ
  • 4
5 Comments
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41895309
could you please provide some patterns of wrongdocument name?
0
 

Author Comment

by:Sam OZ
ID: 41895342
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)
0
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41895351
Please try..

    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

Open in new window


Hope it helps !!
0
 
LVL 17

Accepted Solution

by:
Pawan Kumar Khowal earned 500 total points
ID: 41895354
I think this will be even better..

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 = ""       
      
       Output = str.Substring(str.LastIndexOf("_") + 1)       

    End Sub

Open in new window

1
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41897032
Hi Sam,
Is this done?

Regards,
Pawan
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

12 Experts available now in Live!

Get 1:1 Help Now