RegEx - finding the innermost block

M

msciwoj

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?
 
D

Donato Azevedo

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::parser

Cheers!
 
M

Martijn Lievaart

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
 

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,764
Messages
2,569,567
Members
45,042
Latest member
icassiem

Latest Threads

Top