afr with HTML styles

General discussions about Advanced Find and Replace
Post Reply
Posts: 1
Joined: Tue Apr 05, 2005 8:46 pm

afr with HTML styles

Post by jglaz00 » Tue Apr 05, 2005 8:58 pm

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.

Site Admin
Posts: 1218
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre » Tue Apr 05, 2005 10:28 pm

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>
Kind regards,
Abacre Limited

Post Reply