Page 1 of 1

afr with HTML styles

Posted: Tue Apr 05, 2005 8:58 pm
by jglaz00
I was hoping someone may have thoughts on the following:

I presently have a bunch of files that contain the following HTML code:

<td class="jefftd">bunch of text with spaces here</td>

I need to replace these occurrences with the following:

<td class="jefftd"><span class="jeffspan">same bunch of text goes here</span></td>

I could do the first part pretty easily with a normal find and replace, ie, replacing all occurrences of <td class="jefftd"> with <td class="jefftd"><span class="jeffspan">. However then I would have an open span tag.

I thought about using regular expressions, in the form of:

FIND: <td class="jefftd">(\w+)</td>
REPLACE WITH: <td class="jefftd"><span class="jeffspan">$1</span></td>

But that doesn't work. Any thoughts on how to approach this problem? Note that there are other instances of </td> that do correspond to a plain <td> expression, so I cannot simply just find and replace the </td> with a </span></td>.

Any help is appreciated.

Posted: Tue Apr 05, 2005 10:28 pm
by Abacre
You almost found the right answer, but:
\w means any alphanumeric char. But there are also spaces in your text.

So use the following text in "Search for":
<td class="jefftd">(.+)</td>