Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I write a blog entry in Google blogger then a lot of entries like shown as below are getting inserted in HTML (not sure why).

<span id="textmarked_8" name="textmarker_9" style="background-color: yellow;"></span>

How I do I remove them? Note the numbers 8 and 9 have to be replaced by some regular expression. I am looking for a command in vi or some other easy command. BTW, I am using Ubuntu.

Thanks.

share|improve this question

1 Answer 1

You should really use an HTML-parser not a regex (see past answers on this subject).

However if the XML has completely predictable content and formatting you can get away with something like

:%s/<span[^>]*><\/span>//

(untested) The important point here is that it tests for an empty span element that happens to be all on the same line. You could add a caret (^) at the start if the unwanted span elements always start at the beginning of a new line.

If you want to match id="textmarked_[0-9]* you can do that, I doubt it is necessary. Any empty span element probably serves no useful purpose regardless of it's attributes. The only exception I can think of is if some javascript later populates those elements.

share|improve this answer
    
Worked Thanks !! –  Praveen Sripati Jul 30 '12 at 10:45
1  
@PraveenSripati: Good, I'm glad it helped. Do read the linked article though - this bad habit (using regex on HTML) will bite back viciously sooner or later. –  RedGrittyBrick Jul 30 '12 at 10:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.