Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Parse a line of flat text into fields

  •  10-08-2006, 12:39 AM

    Parse a line of flat text into fields

    Hello,

    I need to parse a line into fields.  This should be relatively easy, but the line will also contain free text, unlabeled, which is also a field.  I am working in .Net (C# or VB works).  This is a new project so I don't have "real" data, but here are some examples:

    • (Z) p:PField c:CField Here is some associated text.
    • (A) p:1 c:Test This is a test string

    The letter in () is a field; p: is a field; c: is a field; the text is a field, and I need to parse it in this way and pull out the interesting data:

    • Line 1: Z, PField, CField, Here is some associated text.
    • Line 2: A, 1, Test, This is a string

    I don't know if position will be a problem, as I'm not schooled enough in regex to to know... what happens if the labeled fields are not in order?

    • p:1 (A) This is a test string c:Test
    • (Z) Here is some associated text. p:PField c:CField

    As far as I can read, you guys are gods!  I read through pages and pages of articles and forums and some of your solutions have been absolutely brilliant!

    Thanks for any help!

    JK
    ---

     

View Complete Thread