How to handle nested regular expression in perl

R

Raghavendra Mahuli

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
 
A

Anno Siegel

Raghavendra Mahuli said:
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
 
R

ritu_minda

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
 
P

Paul Lalli

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top