-1

I need some help with wordpress. I got lots of texts that have a tag with an image in the beginning.

like...

<p><a class="lightbox" href="http://www.musicheadquarter.de/wp-content/uploads/2012/07/chris-robinson-brotherhood-big-moon-ritual-cd-cover.jpg"><img class="alignleft size-thumbnail wp-image-462" title="Chris Robinson Brotherhood Big Moon Ritual CD Cover" src="http://www.musicheadquarter.de/wp-content/uploads/2012/07/chris-robinson-brotherhood-big-moon-ritual-cd-cover-150x150.jpg" alt="Chris Robinson Brotherhood Big Moon Ritual CD Cover" width="150" height="150" /></a>&#8220;Big Moon Ritual&#8221; ist das erste Album von Chris Robinson Brotherhood. Moment mal, der Chris Robinson? Ja genau, der Chris Robinson, Sänger der legendären Black Crowes. Nachdem die Band im vergangenen Jahr leider ihr vorläufiges Ende verkündet hatte, blieb es nicht lange ruhig um Chris und seinen Bruder Rich. Der veröffentlichte bereits vor wenigen Monaten ein Soloalbum, während Chris schon zu Black Crowes-Zeiten die Chris Robinson Brotherhood formierte. Bislang gab es das Quintett allerdings lediglich auf diversen offiziellen Live-Bootlegs zu hören. Damit ist jetzt glücklicherweise Schluß!</p>

And I want to delete this...

<a class="lightbox" href="http://www.musicheadquarter.de/wp-content/uploads/2012/07/chris-robinson-brotherhood-big-moon-ritual-cd-cover.jpg"><img class="alignleft size-thumbnail wp-image-462" title="Chris Robinson Brotherhood Big Moon Ritual CD Cover" src="http://www.musicheadquarter.de/wp-content/uploads/2012/07/chris-robinson-brotherhood-big-moon-ritual-cd-cover-150x150.jpg" alt="Chris Robinson Brotherhood Big Moon Ritual CD Cover" width="150" height="150" /></a>

Sure I can do this by hand, but I got 1000 texts, with this construction.

Can someone help me to delete the first <a> with everything betweet in. like <a>....</a>?

aliteralmind
  • 19,847
  • 17
  • 77
  • 108
DenisCGN
  • 397
  • 1
  • 4
  • 17
  • Sounds like a job for an HTML parser... – Jerry Jul 08 '14 at 12:46
  • Hi Jerry, is this a software programm? I exportet the content in a CSV file. How does this work? – DenisCGN Jul 08 '14 at 12:48
  • It is code, often wrapped in a 'package' that you source from your code. [Here's a list of some HTML parsers](http://en.wikipedia.org/wiki/Comparison_of_HTML_parsers) – Jerry Jul 08 '14 at 12:52
  • One possible solution, export your db tables then open it in an editor such as notepad++ and do a find and replace. – hwnd Jul 08 '14 at 13:40

3 Answers3

2

A simple regex can handle this:

<a class=.+?\<\/a\>

replace it with blank

Rex
  • 76
  • 10
0

or try this.

    <((\/a)|a)[a-zA-Z0-9\.\-\_\s\w\"\=\:\/]*>
bimal
  • 1
  • @user1600867 you can open the csv file an a text editor which supports regex ( like sublime text) . DO a find and replace. Use the above regexp in the find field and leave the replace field empty. – bimal Jul 08 '14 at 13:46
0

Demo Regexr Demo

To remove multiple links The regex you need is :

s/(\<a.*?\/a>)//gi

To remove only the first: The regex you need is :

s/(\<a.*?\/a>)//i