Parsing Text using RegExp - DOTNET

This is a discussion on Parsing Text using RegExp - DOTNET ; Hi Sometime ago i had posted a request for code to parse a line of text containing Quotes and Commas, the code posted by the gentleman did work for sometime but does not work for the following 104528558,"New iPod FM ...

+ Reply to Thread
Results 1 to 7 of 7

Parsing Text using RegExp

  1. Default Parsing Text using RegExp

    Hi

    Sometime ago i had posted a request for code to parse a line of text
    containing Quotes and Commas, the code posted by the gentleman did work for
    sometime but does not work for the following

    104528558,"New iPod FM Transmitter & Car Charger
    $1Res(E107)","/Electronics-photography/Portable-audio-iPods/iPod-accessories/FM-Transmitters-iTrips","Jun
    21 2007 12:28PM","Fixed price offer",29,"$6 Courier Nationwide (Rural +3)
    No pick-ups allowed","$6.00 Courier Nationwide (Rural
    +3)","kjc",,,"kyliec@astra.co.nz",0,3.25,1.71,,1,1,39.95,"Jun 13 2007
    9:00PM","7 days",,"yes","yes","yes","no","no","no",5,,"no"

    the following is the code that does not work for the above
    Regex regex = new
    Regex("((?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")+)\")(,|(?<rowbreak>\\r\\n|\\n|$))");


    Can someone help


    Barry



  2. Default Re: Parsing Text using RegExp

    Barry wrote:
    > Sometime ago i had posted a request for code to parse a line of text
    > containing Quotes and Commas, the code posted by the gentleman did work for
    > sometime but does not work for the following
    >
    > 104528558,"New iPod FM Transmitter & Car Charger
    > $1Res(E107)","/Electronics-photography/Portable-audio-iPods/iPod-accessories/FM-Transmitters-iTrips","Jun
    > 21 2007 12:28PM","Fixed price offer",29,"$6 Courier Nationwide (Rural +3)
    > No pick-ups allowed","$6.00 Courier Nationwide (Rural
    > +3)","kjc",,,"kyliec@astra.co.nz",0,3.25,1.71,,1,1,39.95,"Jun 13 2007
    > 9:00PM","7 days",,"yes","yes","yes","no","no","no",5,,"no"
    >
    > the following is the code that does not work for the above
    > Regex regex = new
    > Regex("((?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")+)\")(,|(?<rowbreak>\\r\\n|\\n|$))");
    >
    >
    > Can someone help


    What exactly do you mean by "does not work"?

    I tried it, and it works just fine.

    --
    Göran Andersson
    _____
    http://www.guffa.com

  3. Default Re: Parsing Text using RegExp

    What type of website are your trying to make?

  4. Default Re: Parsing Text using RegExp

    What type of website are your trying to make?

  5. Default Re: Parsing Text using RegExp

    Yes, it does work, my question was slightly incorrect.

    It works but return ONLY 26 of the 30 expected fields, whenever there are

    "124",,,"152"
    it will show return only 2 fileds not 4 for the above line

    You can try to create a csv file with my line of text and open a excel sheet
    for testing.

    Correct me if i am wrong.



    "Göran Andersson" <guffa@guffa.com> wrote in message
    news:%231U$x6ltHHA.4952@TK2MSFTNGP04.phx.gbl...
    > Barry wrote:
    >> Sometime ago i had posted a request for code to parse a line of text
    >> containing Quotes and Commas, the code posted by the gentleman did work
    >> for sometime but does not work for the following
    >>
    >> 104528558,"New iPod FM Transmitter & Car Charger
    >> $1Res(E107)","/Electronics-photography/Portable-audio-iPods/iPod-accessories/FM-Transmitters-iTrips","Jun
    >> 21 2007 12:28PM","Fixed price offer",29,"$6 Courier Nationwide (Rural +3)
    >> No pick-ups allowed","$6.00 Courier Nationwide (Rural
    >> +3)","kjc",,,"kyliec@astra.co.nz",0,3.25,1.71,,1,1,39.95,"Jun 13 2007
    >> 9:00PM","7 days",,"yes","yes","yes","no","no","no",5,,"no"
    >>
    >> the following is the code that does not work for the above
    >> Regex regex = new
    >>
    >> Regex("((?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")+)\")(,|(?<rowbreak>\\r\\n|\\n|$))");
    >>
    >>
    >> Can someone help

    >
    > What exactly do you mean by "does not work"?
    >
    > I tried it, and it works just fine.
    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com




  6. Default Re: Parsing Text using RegExp

    does it matter, for all you know i may not be trying to make a website at
    all, i could be using it for a different purpose, that is immaterial for the
    posting



    <1store> wrote in message news:OuUVqottHHA.680@TK2MSFTNGP05.phx.gbl...
    > What type of website are your trying to make?




  7. Default Re: Parsing Text using RegExp

    Barry wrote:
    > Yes, it does work, my question was slightly incorrect.
    >
    > It works but return ONLY 26 of the 30 expected fields, whenever there are
    >
    > "124",,,"152"
    > it will show return only 2 fileds not 4 for the above line
    >
    > You can try to create a csv file with my line of text and open a excel sheet
    > for testing.
    >
    > Correct me if i am wrong.
    >
    >
    >
    > "Göran Andersson" <guffa@guffa.com> wrote in message
    > news:%231U$x6ltHHA.4952@TK2MSFTNGP04.phx.gbl...
    >> Barry wrote:
    >>> Sometime ago i had posted a request for code to parse a line of text
    >>> containing Quotes and Commas, the code posted by the gentleman did work
    >>> for sometime but does not work for the following
    >>>
    >>> 104528558,"New iPod FM Transmitter & Car Charger
    >>> $1Res(E107)","/Electronics-photography/Portable-audio-iPods/iPod-accessories/FM-Transmitters-iTrips","Jun
    >>> 21 2007 12:28PM","Fixed price offer",29,"$6 Courier Nationwide (Rural +3)
    >>> No pick-ups allowed","$6.00 Courier Nationwide (Rural
    >>> +3)","kjc",,,"kyliec@astra.co.nz",0,3.25,1.71,,1,1,39.95,"Jun 13 2007
    >>> 9:00PM","7 days",,"yes","yes","yes","no","no","no",5,,"no"
    >>>
    >>> the following is the code that does not work for the above
    >>> Regex regex = new
    >>>
    >>> Regex("((?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")+)\")(,|(?<rowbreak>\\r\\n|\\n|$))");
    >>>
    >>>
    >>> Can someone help

    >> What exactly do you mean by "does not work"?
    >>
    >> I tried it, and it works just fine.
    >>
    >> --
    >> Göran Andersson
    >> _____
    >> http://www.guffa.com

    >


    Yes, the pattern does not include empty items.

    To make it include empty non-quoted items, change the first + to *.

    To make it include empty quoted items, change the second + to *.

    --
    Göran Andersson
    _____
    http://www.guffa.com

+ Reply to Thread

Similar Threads

  1. Regexp for parsing?
    By Application Development in forum RUBY
    Replies: 6
    Last Post: 12-03-2007, 02:00 PM
  2. string parsing / regexp question
    By Application Development in forum Python
    Replies: 5
    Last Post: 11-28-2007, 06:18 PM
  3. Re: string parsing / regexp question
    By Application Development in forum Python
    Replies: 0
    Last Post: 11-28-2007, 12:38 PM
  4. New at regexp and Ruby need help on parsing a string.
    By Application Development in forum RUBY
    Replies: 9
    Last Post: 11-24-2007, 04:29 PM
  5. Regexp to enclose text with P-tag
    By Application Development in forum Perl
    Replies: 1
    Last Post: 05-18-2004, 08:44 AM