|Subject:||Regular Expression to Find HTML Tags|
|Date:||Tue, 23 Dec 2008|
I'm working on an ASP.NET project in Visual Studio 2005. Can someone
help me write a regular expression I can use in the Find/Replace
dialog to find all <p...> tags and simplify them to <p>?
For instance, I'd like an expression which finds the following tag:
<p align="left" style="border-right: medium none; padding-
right: 0pt; border-top: medium none;
margin-top: 0.13in; padding-left: 0pt; margin-bottom:
0.04in; padding-bottom: 0pt;
border-left: medium none; padding-top: 0pt; border-bottom:
medium none; text-align: center">
I wrote this regular expression: \<p[^\>]*\>
It doesn't work, and I don't know why. I've read the help file
carefully, and it should be finding any place in the code where there
is an opening bracket followed by a "p" followed by any set of
characters which are not the closing bracket, followed by the closing
bracket. Nevertheless, it doesn't find the example I showed above.
Another expression I tried is this: \<p[.\
It doesn't work either, and I can't figure out why. It should find any
place in the code where an opening bracket is followed by any set of
characters (which may be either any character except a line break or a
line break, and thus any character) followed by a closing bracket,
choosing the smallest set of characters which satisfies the pattern.
Nevertheless, it doesn't find my example either.
Can anyone explain to me what I'm doing wrong, and propose the right
way to do the search?