Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Created April 29, 2011 20:05
Show Gist options
  • Select an option

  • Save toritori0318/948937 to your computer and use it in GitHub Desktop.

Select an option

Save toritori0318/948937 to your computer and use it in GitHub Desktop.
自信ないけどこんな感じ?
# for perl
my @allowd_tags = qw/redpre pre code notextile/;
my $str = '<html><body> <p><pre>fufufu</pre></p> </body></html>';
$str =~
s{<(\/?([!\w]+)[^<>\n]*)(>?)}
{
if(grep /^$2$/ , @allowd_tags ){
"<$1$3";
}else{
($3) ? "&lt;$1&gt" : "&lt;$1";
}
}ge;
print $str,"\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment