I'd like to remove all attributes of <p>
in an HTML file by using this simple Perl command line:
$ perl -pe 's/<p[^>]*>/<p>/' input.html
However, it won't substitute e.g. <p class="hello">
that spans multiple lines such as
<p
class="hello">
Thus, I attempted to first remove the end of line by doing
# command-1
$ perl -pe 's/\n/ /' input.html > input-tmp.html
# command-2
$ perl -pe 's/<p[^>]*>/<p>/g' input-tmp.html > input-final.html
Questions:
- Is there an option in (Perl) regex to try the match across multiple lines?
- Can I combine the two commands above (command-1 and command-2) into one? Basically, the first command needs to complete execution before the second one starts.
`, not the tag / element itself.
– moey Oct 25 '11 at 10:12