Gentle forestcreature: I strongly endorse the wise advice of others to use a proper HTML parser, but here's another (very) naive regex approach using the Special Backtracking Control Verbs of 5.10+ (see perlre):
>perl -wMstrict -le "my $s = qq{foo\nbar\t<pRe> no\nnot\tnever </PrE> x\ty\nz }; ;; my %replace = ( qq{\n} => '<br/>', qq{\t} => ' ', ); ;; my $pre = qr{ (?i) <pre> [^<]* </pre> }xms; ;; print qq{[[$s]]}; $s =~ s{ $pre (*SKIP) (*FAIL) | ([\n\t]) }{$replace{$1}}xmsg; print qq{[[$s]]}; " [[foo bar <pRe> no not never </PrE> x y z ]] [[foo<br/>bar <pRe> no not never </PrE> x y<br/>z ]]
In reply to Re: regex in form !regex->regex<-!regex
by AnomalousMonk
in thread regex in form !regex->regex<-!regex
by forestcreature
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |