#!/usr/bin/perl use strict; use warnings; while (<DATA>) { s/(<%(?:[^%]+|%[^>])*%>)|'/$1 || ""/eg; print; } __DATA__ Leave this line alone. Remove this quote ' and these two quotes '' from this line. Leave <% the first quote ' %> alone, but remove the second ' one. Remove from <% an open but not closed ' tag. ' Leading quote? <% Multiple ' tags %> ' on one ' <% line ''' work %> too ' !
Running this gives:
Leave this line alone. Remove this quote and these two quotes from this line. Leave <% the first quote ' %> alone, but remove the second one. Remove from <% an open but not closed tag. Leading quote? <% Multiple ' tags %> on one <% line ''' work %> too !
In reply to Re: silly regex question
by Abigail-II
in thread silly regex question
by batkins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |