How to handle nested regular expression in perl

Discussion in 'Perl Misc' started by Raghavendra Mahuli, Nov 14, 2005.

  1. Hi group,

    I am using C regular expression functions regex and regcmp to validate some
    record which are of the form-

    REC1{ 'Bsgf' | 'Cjsdg' | 78 }

    That is a fairly simple job.
    But i have to extend it to handle nested records say like a record REC2
    which contains REC1

    like :

    REC2{'sjsd' | 2 | REC1{'Bsgf' | 'Cjsdg' | 78 }| REC2{ 'Bsgf' | 'Cjsdg' |
    78 }}

    Now the number preceding the nested record tells how many records will be
    present. In this case, it is 2.

    Can u pls suggest some way to handle nested regular expressions in perl.



    Thanks in advance
    Raghavendra Mahuli, Nov 14, 2005
    #1
    1. Advertising

  2. Raghavendra Mahuli

    Anno Siegel Guest

    Raghavendra Mahuli <> wrote in comp.lang.perl.misc:
    > Hi group,
    >
    > I am using C regular expression functions regex and regcmp to validate some
    > record which are of the form-
    >
    > REC1{ 'Bsgf' | 'Cjsdg' | 78 }


    A single example tells us nothing about the general form. You must
    specify which parts of the pattern can vary in which ways.

    > That is a fairly simple job.
    > But i have to extend it to handle nested records say like a record REC2
    > which contains REC1
    >
    > like :
    >
    > REC2{'sjsd' | 2 | REC1{'Bsgf' | 'Cjsdg' | 78 }| REC2{ 'Bsgf' | 'Cjsdg' |
    > 78 }}


    In the example REC2 contains a one REC1 and another REC2. Is that an error?

    > Now the number preceding the nested record tells how many records will be
    > present. In this case, it is 2.
    >
    > Can u pls suggest some way to handle nested regular expressions in perl.


    You have a nested data structure. I don't know what a nested regular
    expression would be.

    In general it is notoriously hard to deal with nested data structures
    with regular expressions alone. Perl offers some possibilities (see
    perldoc -q nesting), but I doubt they carry over to a C/regcmp situation.

    In Perl, I'd probably write a record parser (based on Parse::RecDescent)
    and restrict regular expressions to the recognition of lexical elements.

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
    Anno Siegel, Nov 14, 2005
    #2
    1. Advertising

  3. Raghavendra Mahuli

    Guest

    Hi group members,
    i split 1 file's columns and now i want to save 1 column in 1 file and
    2 column in another file .do you guys have any idea about it.
    thanks
    Raghavendra Mahuli wrote:
    > Hi group,
    >
    > I am using C regular expression functions regex and regcmp to validate some
    > record which are of the form-
    >
    > REC1{ 'Bsgf' | 'Cjsdg' | 78 }
    >
    > That is a fairly simple job.
    > But i have to extend it to handle nested records say like a record REC2
    > which contains REC1
    >
    > like :
    >
    > REC2{'sjsd' | 2 | REC1{'Bsgf' | 'Cjsdg' | 78 }| REC2{ 'Bsgf' | 'Cjsdg' |
    > 78 }}
    >
    > Now the number preceding the nested record tells how many records will be
    > present. In this case, it is 2.
    >
    > Can u pls suggest some way to handle nested regular expressions in perl.
    >
    >
    >
    > Thanks in advance
    , Nov 14, 2005
    #3
  4. Raghavendra Mahuli

    Paul Lalli Guest

    Splitting a file on columns

    wrote:
    > Hi group members,
    > i split 1 file's columns and now i want to save 1 column in 1 file and
    > 2 column in another file .


    What does this have to do with the message you replied to? If you want
    to start a new thread, start a new thread. Do not just hit reply on
    any old message you find in the group.

    > do you guys have any idea about it.


    I have several. Do you?

    What have you tried so far? How did it not do what you want? What
    part do you need help with? Where is the code from your failed attempt?

    Have you read the posting guidelines for this group? They're posted
    here twice a week.

    Paul Lalli
    Paul Lalli, Nov 14, 2005
    #4
  5. Raghavendra Mahuli

    Guest

    wrote:
    > Hi group members,
    > i split 1 file's columns and now i want to save 1 column in 1 file and 2 column
    > in another file .do you guys have any idea about it. thanks


    I'm tempted to answer this, because the answer is so simple, but I will
    refrain because the post is so bad and violates so many posting
    guidelines.

    Advise the OP to read
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    and try again.
    , Nov 14, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,267
  2. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    829
    Alan Moore
    Dec 2, 2005
  3. GIMME
    Replies:
    3
    Views:
    11,917
    vforvikash
    Dec 29, 2008
  4. a
    Replies:
    9
    Views:
    1,547
    David Harmon
    Sep 10, 2006
  5. Noah Hoffman

    regular expression for nested parentheses

    Noah Hoffman, Dec 9, 2007, in forum: Python
    Replies:
    5
    Views:
    570
    John Machin
    Dec 10, 2007
Loading...

Share This Page