Regular expression class with child/parent

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 7
Reputation: elpablo is an unknown quantity at this point 
Solved Threads: 0
elpablo elpablo is offline Offline
Newbie Poster

Regular expression class with child/parent

 
0
  #1
Jan 28th, 2009
Hi,

I'm trying to figure out what would be the best way to develop a regular expression class that can have child or parent.

I want to develop a generic regex extractor for text files.

Example :
- An HTML file has a table
- Each table has some data (let's say classes)
- Each class has some properties.
- Each property can have multiple data (array).
- So on

We need :
- A regex to extract each class which are a subtable in the main table.
- Regexes for each properties that are rows.
- Regexes for each value in an array

You see scheme. So I need a recursive class or something like that.

Does someone have an idea of what could be a good design?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Regular expression class with child/parent

 
0
  #2
Jan 28th, 2009
so, is a class represented by a row in the table? if so, easy.. just look for the tr tags
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,047
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Regular expression class with child/parent

 
1
  #3
Jan 28th, 2009
Originally Posted by elpablo View Post
You see scheme. So I need a recursive class or something like that.
What the **** is a recursive class? What the **** are you talking about?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Regular expression class with child/parent

 
0
  #4
Jan 28th, 2009
Perhaps he means a linked list?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 7
Reputation: elpablo is an unknown quantity at this point 
Solved Threads: 0
elpablo elpablo is offline Offline
Newbie Poster

Re: Regular expression class with child/parent

 
0
  #5
Jan 29th, 2009
Originally Posted by LizR View Post
Perhaps he means a linked list?
Sort of a linked list. It's not only a question of <tr> tags. Inside each <tr> there could be other sets of values I need to extract, inside these values, their might be other values and so on.

So a regular expression could bear a set of other regular expression.

Algorithm:
  1. matches m_parent = regex_Parent.match(text)
  2. foreach (x in m_parent)
  3. {
  4. load set of sub_regexes
  5. foreach r in the set of sub_regexes
  6. {
  7. matches m_child = r.match (x)
  8. ...
  9. load set of sub_sub...
  10. ... so on
  11. }
  12. }

An application of this extractor could be extracting results of a google query. There are blocks of pages and in each block there's some info.
The same application could work with yahoo, pirate bay, etc. Only the regex file could be change.


Rashakil : Please stay polite, your answer is very non professional.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,047
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Regular expression class with child/parent

 
2
  #6
Jan 29th, 2009
Originally Posted by elpablo View Post
Rashakil : Please stay polite, your answer is very non professional.
I am a professional programmer, so that means my answer is by definition professional
Last edited by Rashakil Fol; Jan 29th, 2009 at 11:36 am.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 7
Reputation: elpablo is an unknown quantity at this point 
Solved Threads: 0
elpablo elpablo is offline Offline
Newbie Poster

Re: Regular expression class with child/parent

 
0
  #7
Jan 29th, 2009
Originally Posted by Rashakil Fol View Post
I am a professional programmer, so that means my answer is by definition professional

Ok then... as a professional answer it wasn't useful.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Regular expression class with child/parent

 
0
  #8
Jan 29th, 2009
Originally Posted by elpablo View Post
Sort of a linked list. It's not only a question of <tr> tags. Inside each <tr> there could be other sets of values I need to extract, inside these values, their might be other values and so on.

Well the regexpression would handle that just fine...
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,047
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Regular expression class with child/parent

 
1
  #9
Jan 29th, 2009
I think it would help if you specified more precisely what you expect the input text to be, and gave examples.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 7
Reputation: elpablo is an unknown quantity at this point 
Solved Threads: 0
elpablo elpablo is offline Offline
Newbie Poster

Re: Regular expression class with child/parent

 
0
  #10
Jan 31st, 2009
I want to create an application that could extract any structured data. Kind of a generic parser.

Examples :
- Google results
- CNN news
- Forums
- Engadget
- ...

All these website have structured data. Except all of them are structured diffently. It could be easy to extract data from them using a structured tree of regular expressions.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC