Click here to Skip to main content
15,926,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# Online Quotation System Pin
Dave Sexton21-Mar-08 7:52
Dave Sexton21-Mar-08 7:52 
GeneralRe: c# Online Quotation System Pin
pmarfleet21-Mar-08 8:23
pmarfleet21-Mar-08 8:23 
GeneralRe: c# Online Quotation System Pin
Paul Conrad21-Mar-08 8:07
professionalPaul Conrad21-Mar-08 8:07 
General[Message Deleted] Pin
Roman Olney21-Mar-08 8:31
Roman Olney21-Mar-08 8:31 
GeneralRe: c# Online Quotation System Pin
Paul Conrad21-Mar-08 9:14
professionalPaul Conrad21-Mar-08 9:14 
GeneralRe: c# Online Quotation System Pin
led mike21-Mar-08 9:31
led mike21-Mar-08 9:31 
GeneralTrying to parse legacy data with RegEx [modified] Pin
Steve Messer21-Mar-08 5:49
Steve Messer21-Mar-08 5:49 
GeneralRe: Trying to parse legacy data with RegEx Pin
#realJSOP21-Mar-08 6:04
professional#realJSOP21-Mar-08 6:04 
You don't parse with regular expressions.

Try something like this:
private string SplitValue(string str, char delim)
{
    string[] parts = str.Split(delim);
    return parts[1];
}
//--------------------------------------------------------------------------------
private bool Test7()
{
    bool result = false;
    string original = "LIC#:ABC123 YRMD:03 MAKE:CHEV BTM :CP VIN :1G1JC12F137230800";
    string[] parts = original.Split(' ');

    if (parts.Length != 7)
    {
        return result;
    }
    string license = SplitValue(parts[0], ':');
    string yrmd = SplitValue(parts[1], ':');
    string make = SplitValue(parts[2], ':'); ;
    string btm = parts[4].Replace(":", "");
    string vin = parts[6].Replace(":", "");

    return true;
}


The code above is based on the string you provided. Since there appear to be spaces in places where there really should be none, you can't really get away with a single split command, so you have to improvise. Yeah, I could have used substring instead of writing another function to split the first three parts, but what the hell, I had time...


"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


GeneralRe: Trying to parse legacy data with RegEx Pin
Steve Messer21-Mar-08 6:17
Steve Messer21-Mar-08 6:17 
GeneralRe: Trying to parse legacy data with RegEx Pin
PIEBALDconsult21-Mar-08 6:23
mvePIEBALDconsult21-Mar-08 6:23 
GeneralRe: Trying to parse legacy data with RegEx Pin
Steve Messer21-Mar-08 6:35
Steve Messer21-Mar-08 6:35 
GeneralRe: Trying to parse legacy data with RegEx Pin
User 665821-Mar-08 6:23
User 665821-Mar-08 6:23 
GeneralRe: Trying to parse legacy data with RegEx [modified] Pin
Steve Messer21-Mar-08 6:35
Steve Messer21-Mar-08 6:35 
GeneralRe: Trying to parse legacy data with RegEx [modified] Pin
PIEBALDconsult21-Mar-08 7:31
mvePIEBALDconsult21-Mar-08 7:31 
GeneralRe: Trying to parse legacy data with RegEx Pin
Dan Neely21-Mar-08 7:52
Dan Neely21-Mar-08 7:52 
GeneralRe: Trying to parse legacy data with RegEx Pin
Steve Messer21-Mar-08 7:58
Steve Messer21-Mar-08 7:58 
GeneralRe: Trying to parse legacy data with RegEx [modified] Pin
PIEBALDconsult21-Mar-08 8:06
mvePIEBALDconsult21-Mar-08 8:06 
GeneralRe: Trying to parse legacy data with RegEx Pin
ChrisKo21-Mar-08 9:10
ChrisKo21-Mar-08 9:10 
GeneralRe: Trying to parse legacy data with RegEx Pin
PIEBALDconsult21-Mar-08 10:00
mvePIEBALDconsult21-Mar-08 10:00 
GeneralRe: Trying to parse legacy data with RegEx Pin
ChrisKo21-Mar-08 10:57
ChrisKo21-Mar-08 10:57 
GeneralRe: Trying to parse legacy data with RegEx [modified] Pin
Steve Messer21-Mar-08 12:08
Steve Messer21-Mar-08 12:08 
GeneralRe: Trying to parse legacy data with RegEx Pin
PIEBALDconsult21-Mar-08 12:52
mvePIEBALDconsult21-Mar-08 12:52 
GeneralA form from a dll Pin
c6jones72021-Mar-08 3:54
c6jones72021-Mar-08 3:54 
GeneralRe: A form from a dll Pin
darkelv21-Mar-08 4:11
darkelv21-Mar-08 4:11 
GeneralRe: A form from a dll Pin
c6jones72021-Mar-08 4:23
c6jones72021-Mar-08 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.