Question

Search

<img src="images/foo.jpg" alt="" title="caption here" class="figure" />

replace with

<img src="images/foo.jpg" alt="" title="caption here" class="figure" /><figcaption>caption here</figcaption>

or just (my second choice, good enough)

<figcaption>caption here</figcaption>

How do I search and replace with regex? I am using TextMate and Espresso. I am not searching in a HTML file, this HTML is small part of my Drupal post. I learnt I should be using a HTML parser. I believe this case is simpler.

Était-ce utile?

La solution

Try searching with:

(<img[^>]+?title=['"])([^'"]*?)(['"][^>]+?>)

and replace with:

$1$2$3<figcaption>$2</figcaption>

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top