Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > RegEx - finding the innermost block

Reply
Thread Tools

RegEx - finding the innermost block

 
 
msciwoj
Guest
Posts: n/a
 
      07-16-2009
Does any one have an idea is it possible to catch the block that has
no nested blocks of its type using regular expressions?
In other words how to catch
<blockbeginmark>.....-NO <blockbeginmark> until <blockendmark>

For instance, can
<div> ..... </div>
block can be caught with the condition it has no nested <div> blocks
in it?

Any ideas?
 
Reply With Quote
 
 
 
 
Donato Azevedo
Guest
Posts: n/a
 
      07-16-2009
On Jul 16, 7:51*am, msciwoj <m...@epf.pl> wrote:
> Does any one have an idea is it possible to catch the block that has
> no nested blocks of its type using regular expressions?
> In other words how to catch
> <blockbeginmark>.....-NO <blockbeginmark> until <blockendmark>
>
> For instance, can
> <div> ..... </div>
> block can be caught with the condition it has no nested <div> blocks
> in it?
>
> Any ideas?


Regular Expressions are not really good for context aware matching and
parsing (which is what your match looks to be). For that, I would
recommend you do a little search on CPAN for HTML parsing modules such
as HTML:arser

Cheers!
--
Donato Azevedo
 
Reply With Quote
 
 
 
 
Martijn Lievaart
Guest
Posts: n/a
 
      07-18-2009
On Thu, 16 Jul 2009 03:51:05 -0700, msciwoj wrote:

> Does any one have an idea is it possible to catch the block that has no
> nested blocks of its type using regular expressions? In other words how
> to catch
> <blockbeginmark>.....-NO <blockbeginmark> until <blockendmark>
>
> For instance, can
> <div> ..... </div>
> block can be caught with the condition it has no nested <div> blocks in
> it?


Yes, use a html parser. There are many on CPAN and they work much better
that any regex you can come up with.

M4
 
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
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
Why Does Asp.Net Use The Innermost Exception? =?Utf-8?B?Sm9obkRlSG9wZTM=?= ASP .Net 3 07-17-2006 05:18 PM
Innermost containing tag: match/replace it w_laks@yahoo.com Perl Misc 0 01-20-2005 08:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57