none
Trimming text RRS feed

  • Question

  • Hi Everyone,

    I have a console application that I am creating for work that will write values from a folder to an Excel spreadsheet.  To explain more verbosely, I get check-in emails daily from our developers.  I copy the emails to Outlook express (since it uses the .eml format I need), then copy them to a folder on my local drive.  From there, I have code that reads the mark-up for the email and dumps certain values from them to my spreadsheet.

    Now, herein lies the problem.  I have the code writing exactly what I need, there is just more of it than I want.  Below is an example:

    Most times, there is text following the ticket number: 

    B2C-73767 removed scrolling

    Other times, the text comes before:

    updated for ECOMATG91-12

    And sometimes the text comes before and after the ticket number:

    Reversion to previous version. Mistakenly committed B2C-73375 changes to FS.

    What I need is to, in all cases, be able to remove the text and retain only the ticket number.

    Here is a snippet of the code I use to get the ticket number:

    TicketNumber = GetStringInBetween("Log:<BR>", "<BR><BR>", EmailText, false, false);
    if (CheckInNotes.Contains("B2C-") || CheckInNotes.Contains("B2C-".ToLower()) || CheckInNotes.Contains("Ecomatg") ||
       CheckInNotes.Contains("Ecomatg".ToLower()) || CheckInNotes.Contains("Ecom") || CheckInNotes.Contains("Ecom".ToLower())
       || CheckInNotes.Contains("Zodiac") || CheckInNotes.Contains("Zodiac".ToLower()))
       TicketNumber = CheckInNotes.Trim().ToString();
    else
       TicketNumber = "N/A";
    

    Any thoughts/suggestions?

    Thanks,

    Brian

    IDesign : ICode

    Monday, December 20, 2010 7:50 PM

Answers

  • Hi Brain,

     

    Does the ticket number has any fixed schema, e.g. length, prefix, suffix? If so, you may consider use Regular Expression to extra ticket number.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by eryang Monday, December 27, 2010 9:54 AM
    Tuesday, December 21, 2010 3:21 AM