in reply to Re: Excluding groups of characters in regular expressions
in thread Excluding groups of characters in regular expressions

A friend of mine was able to help me... here is the answer for anybody who needs help with this sort of thing in the future.

$_='$0<paragraph>$1<paragraph>$2</paragraph>$3<paragraph>$4<paragraph> +$5</paragraph>$6</paragraph>$7</paragraph>$8<paragraph>$9</paragraph> +$10<paragraph>$11</paragraph>$12 '; ($re=$_)=~s/((<paragraph>)|(<\/paragraph>)|[^<]+|.)/${[')','']}[!$3]\Q +$1\E${['(','']}[!$2]/gs; $re=join"|",map{quotemeta}(eval{/$re/}); s{($re)}{local $_=$1;s#</?paragraph>##g;$_}eg; print;


Tom

Replies are listed 'Best First'.
Re^3: Excluding groups of characters in regular expressions
by suaveant (Parson) on Dec 21, 2007 at 19:52 UTC
    Have you ever heard anyone discussing your friend's code before... and if so, was there a lot of swearing involved?

    No offense, but the code looks like an entry to an obfuscation contest. Not so bad if its a one off script, but barely maintainable if it's going to be around for a bit.

                    - Ant
                    - Some of my best work - (1 2 3)