Page 1 of 1

Help with Regular Expression

Posted: Fri Jul 18, 2003 11:32 pm
by mo
I cannot work out the regular expression that would do the following:

Given a line that looks like this:
<p class="mozp">(Gavesisuttam)</p>

I want to end up with a line that looks like this:
<h4>Gavesisuttam</h4>

I cannot look just for "<p class="mozp">" as it occurs on every line.

The unique thing in this line is the "suttam)"

I have tried variations of the following:

^<p class="mozp">(\<[.*]suttam)</p>$
^<p class="mozp">\(\<[.*]suttam\)</p>$
^<p class="mozp">\\(\<[.*]suttam\\)</p>$
^<p class="mozp">\([.*]suttam\)</p>$
^<p class="mozp">\\([.*]suttam\\)</p>$

^<p class="mozp">\(\(\([^<]+\)suttaµ\)</p>$

Any help would be appreciated.

Posted: Sat Jul 19, 2003 6:23 am
by bbadmin
Try this, using POSIX syntax:

Find what: <p class="mozp">\((.+)suttam\)</p>
Replace with: <h4>\1suttam</h4>

or this, with non-POSIX syntax:

Find what: <p class="mozp">(\(.+\)suttam)</p>

Keith MacDonald
Helios Software Solutions

Posted: Sat Jul 19, 2003 12:57 pm
by mo
Thanks Keith that works fine. Saves me a huge amount of work.

Any guidelines as to when one should be using POSIX? I don't because I havn't, not because I know why not.

mo

Posted: Sat Jul 19, 2003 2:58 pm
by bbadmin
Using POSIX syntax is just a matter of preference. One way or the other you have to escape brackets!

Keith MacDonald
Helios Software Solutions