Perhaps you just want to remove any patterns that are not allowed...
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152608 use warnings; my @lines = split /^/, <<END; xxx<pre>xxx<www>xxx<strong>xxx xxx<pre>xxxxxx<strong>xxx xxx<pre>xxx<pr>xxx<strong>xxx xxx<pre>xxx<pree>xxx<strong>xxx xxx<pre>xxx<strong>xxx<strong>xxx xxx<pre>xxx<pre>xxx<strong>xxx END my %allowed = map { ( '<'.$_.'>' ) x 2 } qw( pre strong ); for ( @lines ) { my $clean = s[<\w+>][ $allowed{$&} // '' ]ger; print $clean; }
Outputs:
xxx<pre>xxxxxx<strong>xxx xxx<pre>xxxxxx<strong>xxx xxx<pre>xxxxxx<strong>xxx xxx<pre>xxxxxx<strong>xxx xxx<pre>xxx<strong>xxx<strong>xxx xxx<pre>xxx<pre>xxx<strong>xxx
In reply to Re: perlre inverse check for several patterns
by tybalt89
in thread perlre inverse check for several patterns
by averlon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |