Splitting Strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pkj7461
    New Member
    • Oct 2007
    • 15

    Splitting Strings

    I want to split a string based on a pattern. my string is something like this.

    10/8/2007 5:03:06 PM thakurab *************RE CIVED MAIL FROM MIKE FOR THE PQR AND DPS CRETION******** *************** PQR Start Time: 10/08/07 16:29:09 New PQR State: Assigned Respond Due Date: 10/09/07 00:29:09 Resolve Due Date: 10/10/07 16:29:09 Resolved On: 10/8/2007 5:23:40 PM pandeyra



    usually, there is date/time in the start of sentence followed by the name(thakurab, in this case). the string has to split after this combination. the result shuld be something like this:




    10/8/2007 5:03:06 PM thakurab

    *************RE CIVED MAIL FROM MIKE FOR THE PQR AND DPS CRETION******** *************** PQR Start Time: 10/08/07 16:29:09 New PQR State: Assigned Respond Due Date: 10/09/07 00:29:09 Resolve Due Date: 10/10/07 16:29:09

    10/8/2007 5:23:40 PM pandeyra


    plz guide me through this. Also, will regex help in achieving this?

    Thanks,
    Prasanna.
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Where are your strings coming from? XML, database, textfile? If you know the name that you are looking for you could use the IndexOf method to find the name then insert a <br> tag to create a new line. Provide more info please.

    Nathan

    Comment

    • Shashi Sadasivan
      Recognized Expert Top Contributor
      • Aug 2007
      • 1435

      #3
      What happened to "Resolved On: " ? :P
      yes regex will seem to be very helpful as you know you have to find the indexes of the dates.
      Except you have to figure out which date to split the string from.

      cheers

      Comment

      • KnightHack
        New Member
        • Oct 2007
        • 15

        #4
        You have to know 1st format

        inside this string getting 2 date times and

        everytime the format is changing,if you use regex also be how u get,

        TRY THIS

        dim str as string = "ffdfdsf f23183913 fdsfsf ********* "

        STR = STR.SUBSTRING(0 OR 1 ,INSTR(STR,"**" ) - 0 OR 1)
        GOOD LUCK

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Will the String.Split method help?

          Comment

          Working...