Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Properly transforming strings with nested markup tags

by I0 (Priest)
on Dec 29, 2001 at 10:09 UTC ( [id://135080]=note: print w/replies, xml ) Need Help??


in reply to Properly transforming strings with nested markup tags

my $string = q( Outside. {tag} Inside level 1. {tag} Inside level 2. {/tag} Inside level 1. {/tag} Outside. ); (my $re=$string)=~s/((\{tag\})|(\{\/tag\})|.)/${[')','']}[!$3]\Q$1\E${ +['(','']}[!$2]/gs; @$ = (eval{$string=~/$re/}); die $@ if $@=~/unmatched/; $re = join("|",map{quotemeta}@$); print $string while $string=~s/\{tag\}($re)\{\/tag\}/--Marked--\n$1\n- +-EndMarked--/;

Replies are listed 'Best First'.
Re: Re: Properly transforming strings with nested markup tags
by tocie (Novice) on Dec 29, 2001 at 12:11 UTC
    Wow.

    Er, I think. Thank you. I'll go over that when my eyes focus. ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://135080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-03-29 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found