Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to handle nested regular expression in perl

Reply
Thread Tools

How to handle nested regular expression in perl

 
 
Raghavendra Mahuli
Guest
Posts: n/a
 
      11-14-2005
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


 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      11-14-2005
Raghavendra Mahuli <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
ritu_minda@yahoo.co.in
Guest
Posts: n/a
 
      11-14-2005
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


 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      11-14-2005
(E-Mail Removed) 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

 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      11-14-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/cl...uidelines.html
and try again.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
regular expression for nested parentheses Noah Hoffman Python 5 12-10-2007 06:26 AM
Regular expression to match a nested quoted string a C++ 9 09-10-2006 07:05 AM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments