Based on that write a parser which follows your rules. A parser loads actual syntax into a parse tree but in your example, a hash will suffice. This is just to start you off...
You'll also need a simple routine Exhausted to make sure nothing is left inside a tag and something to deal with the closing of a named tag -- enough said?my $remains = $string; my %parsed = (); while ( $remains =~ /^\s*\<(.*)$/ ) { # for each tag... $remains = $1; #we expect an identifier ( $remains =~ /^\s*(\w+)(.*)$/ ) or die 'expected identifier'; my $kwd = $1; $remains = $2; if ( $kwd eq 'vertical' ) { ( $remains =~ /^\s*(\w+)\s*\=\s*(\w+)(.*)$/ or die 'expected a +ssignment'; $parsed{ $kwd } and die 'duplicate definition'; $parsed{ $kwd }{ $1 } = $2; $remains = $2; Exhausted( \$remains ); next; # next tag } if ... # next tag processor goes here }
-S
One world, one people
In reply to Re: some more Regex help reqd
by anonymized user 468275
in thread some more Regex help reqd
by Ananda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |