#!/usr/bin/perl use strict; use warnings; undef $/; $_ = <DATA>; my %repl = qw / < < > > foo bar bar foo /; s/(<\s*br\s*>|[<>]|foo|bar)/$repl{$1}||$1/ge; print; __DATA__ <br> Don't do the regex < br > Don't do the regex < br> Don't do the regex <br > Don't do the regex <this> Do the regex <is> Do the regex <a> Do the regex <test> Do the regex <this is a test> Do the regex <br> Don't do the regex < br > Don't do the regex < br> Don't do the regex <br > Don't do the regex <this> Do the regex <is> Do the regex <a> Do the regex <test> Do the regex <this is a test> Do the regex
Abigail
In reply to Re: Regular expression question
by Abigail-II
in thread Regular expression question
by TASdvlper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |