I’m writing an HTML obfuscator, and I have a hash correlating user-friendly names (of ids and classes) to obfuscated names (like a,b,c,etc). I’m having trouble coming up with a regexp for accomplishing replacing something like
<div class="left tall">
with
<div class="a b">
If tags could only accept one class, the regexp would simply be something like
s/(class|id)="(.*?)"/$1="$hash{$2}"/
How should I correct this to account for for multiple class names within quotes? Preferrably, the solution should be Perl compatible.
I guess I’d do this: