Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
I don't know if anyone on here has touched regular expressions yet, but I'm trying to learn them, so here goes.
I have some text I'm messing with removing certain HTML elements from.
Code:
<b>Bold</b>
<a href="anchor text">Anchor</a>
<i>Italic</i>
<strong>Strong</strong>
<em>em</em>
<blockquote>Blockquote</blockquote>
<ol>
<li>Ordered List</li>
</ol>
<ul>
<li>Ordered List</li>
</ul>
<p>Paragraph</p>
<sup>Superscript</sup>
<br />
<sub>Subscript</sub>
<div>Div</div>
<img src="something-cool.jpg" />
<h1>Heading 1</h1>
Now, when I apply this regular expression:
<([^bai](.*))>
I get the following, which is what I expected:
Code:
</b>
</a>
</i>
<strong>Strong</strong>
<em>em</em>
</blockquote>
<ol>
<li>Ordered List</li>
</ol>
<ul>
<li>Ordered List</li>
</ul>
<p>Paragraph</p>
<sup>Superscript</sup>
<sub>Subscript</sub>
<div>Div</div>
<h1>Heading 1</h1>
Which is what I expected (since the pattern doesn't check for a closing tag for </b>, </a>, </i>, and </blockquote>
However, what's weird is that I get the same thing when I apply the following expressions, I get the exact same thing!
</?([^bai](.*))>
</*([^bai](.*))>
<\047*([^bai](.*))>
<\047?([^bai](.*))>
</{0,1}([^bai](.*))>
<\047{0,1}([^bai](.*))>
I don't understand why that would be, since the pattern should match for both </ (which it doesn't) and < (which it does).
Any help? Thanks.
Last edited by ADAM Web Design : 12-23-2006 at 05:38 PM.
|