title: MYSQL Replace string between two known strings
body: <p>Edit 1: I am trying to fetch using this below query but problem is that the end div is not taken the occurrence after the start Point i.e 
  
  <pre><code>select ID, post_title, substr(post_content,instr(post_content,'&lt;div style="position:absolute') + 0, instr(post_content,'&lt;/div&gt;')) as temp from wp_posts where post_content LIKE '%mySpamFilter Text%' LIMIT 10
  </code></pre>
  
  <p>One of my Blog has been attacked by spammers, I have around 100+ posts which have the unwanted links or messages which was fused by spammers. I want to know how can I replace the string between two strings. </p>
  
  <pre><code>Start string = '&lt;div style="position:absolute;'
  End String = '&lt;/div&gt;'  (This End div should be the first end div after the above Start string)
  </code></pre>
  
  <p>I tried all the options which is available on Stack overflow but no luck so far. Please advice whats the best approach to go ahead.  below is content of post_content column from one of the post from wp_posts table
  You can see after the word Paneer there is a lot of spam between a div class. I want to get rid of this from my database.   I don't how I became victim of this attack but for now I just want to delete these.</p>
  
  <pre><code> &lt;p&gt;Hey Foodies,&lt;/p&gt;
  &lt;p&gt;Biryani, the pride of Hyderabad, is definitely one dish which everyone knows to cook in their very own ways and styles. Biryani is one such thing which totally distinguishes itself with the plain rice we eat daily and the regular pulao. Biryani is the BIRYANI. So, lets look into the detailed procedure of the much loved Hyderabadi delicacy, the vegetarian version. Oh yes, this is the Hyderabadi Dum Veg Biryani!&lt;/p&gt;
  &lt;p&gt;This recipe would take 380-400 grams of uncooked Basmati rice which would serve 6.&lt;/p&gt;
  &lt;div class="easyrecipe"&gt;
  &lt;link itemprop="image" href="http://mywebsite.in/wp-content/uploads/2013/09/Biryani-300x225.jpg"&gt;
  &lt;div class="item ERName"&gt;Hyderabadi Veg Dum Biryani&lt;/div&gt;
  &lt;div class="ERClear"&gt;&lt;/div&gt;
  &lt;div class="ERHead"&gt;&lt;span class="xlate"&gt;Recipe Type&lt;/span&gt;: &lt;span class="type"&gt;Main Course&lt;/span&gt;&lt;/div&gt;
  &lt;div class="ERHead"&gt;Cuisine: &lt;span class="cuisine"&gt;Indian&lt;/span&gt;&lt;/div&gt;
  &lt;div class="ERHead"&gt;Prep time: &lt;time itemprop="prepTime" datetime="PT30M"&gt;30 mins&lt;/time&gt;&lt;/div&gt;
  &lt;div class="ERHead"&gt;Cook time: &lt;time itemprop="cookTime" datetime="PT1H15M"&gt;1 hour 15 mins&lt;/time&gt;&lt;/div&gt;
  &lt;div class="ERHead"&gt;Total time: &lt;time itemprop="totalTime" datetime="PT1H45M"&gt;1 hour 45 mins&lt;/time&gt;&lt;/div&gt;
  &lt;div class="ERHead"&gt;Serves: &lt;span class="yield"&gt;6&lt;/span&gt;&lt;/div&gt;
  &lt;div class="ERIngredients"&gt;
  &lt;div class="ERIngredientsHeader"&gt;Ingredients&lt;/div&gt;
  &lt;ul class="ingredients"&gt;
  &lt;li class="ingredient"&gt;For Vegetables: Carrot - 1 medium&lt;/li&gt;
  &lt;li class="ingredient"&gt;Potatoes - 1 medium&lt;/li&gt;
  &lt;li class="ingredient"&gt;Paneer ***&lt;div style="position:absolute; left:-3905px; top:-3984px;"&gt;Gloves fast it &lt;a href="http://www.goprorestoration.com/natural-viagra-foods"&gt;natural viagra foods&lt;/a&gt; recently! Like as &lt;a href="http://www.backrentals.com/shap/daily-cialis.html"&gt;daily cialis&lt;/a&gt; the purchase 1 pad &lt;a href="http://www.vermontvocals.org/buy-online-cialis.php"&gt;generic viagra cheap&lt;/a&gt; and matte easy &lt;a href="http://www.teddyromano.com/blue-pills/"&gt;blue pills&lt;/a&gt; me many. Content but &lt;a href="http://augustasapartments.com/qhio/10-mg-cialis"&gt;10 mg cialis&lt;/a&gt; the as the helps Amazon &lt;a href="http://www.mordellgardens.com/saha/cheap-viagra-canada.html"&gt;http://www.mordellgardens.com/saha/cheap-viagra-canada.html&lt;/a&gt; . And baths etc would. I've &lt;a href="http://www.teddyromano.com/brand-cialis/"&gt;brand cialis&lt;/a&gt; Appears dollars hands still &lt;a href="http://www.backrentals.com/shap/generic-cialis-europe.html"&gt;shop&lt;/a&gt; October a smell &lt;a href="http://www.hilobereans.com/buy-real-viagra/"&gt;http://www.hilobereans.com/buy-real-viagra/&lt;/a&gt; in have. Of better &lt;a href="http://www.creativetours-morocco.com/fers/herbal-viagra-australia.html"&gt;cheap generic cialis&lt;/a&gt; it smelled to and &lt;a rel="nofollow" href="http://www.goprorestoration.com/best-price-viagra"&gt;best price viagra&lt;/a&gt; t customer anything been &lt;a href="http://www.mordellgardens.com/saha/viagra-online-reviews.html"&gt;viagra online reviews&lt;/a&gt; 5 supply time &lt;a href="http://www.hilobereans.com/viagra-canada-pharmacy/"&gt;"here"&lt;/a&gt; the product what &lt;a href="http://www.vermontvocals.org/ed-supplements.php"&gt;buy levitra&lt;/a&gt; biological by cream!&lt;/div&gt;***  - 1/2 cup&lt;/li&gt;
  &lt;li class="ingredient"&gt;Cauliflower - 1/2 cup&lt;/li&gt;
  &lt;li class="ingredient"&gt;Green peas - 1 tbsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Yogurt - 1/2 cup&lt;/li&gt;
  &lt;li class="ingredient"&gt;Mint - 1 tbsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Coriander - 1 tbsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Ginger-Garlic paste - 1 tsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Green chili - 4 to 5&lt;/li&gt;
  &lt;li class="ingredient"&gt;Oil - 2 tbsp&lt;/li&gt;
  &lt;li class="ingredient"&gt;Salt - As per taste&lt;/li&gt;
  &lt;li class="ingredient"&gt;Biryani Masala - 1 and 1/2 tbsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Red Chili Powder - 1/2 tsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Garam Masala Powder - 1/4 tsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Whole Garam Masala - Custom or readymade&lt;/li&gt;
  &lt;li class="ingredient"&gt;For Rice: Basmati Rice(soaked for 1 hour) - 380 gms&lt;/li&gt;
  &lt;li class="ingredient"&gt;Water - 6-8 cups&lt;/li&gt;
  &lt;li class="ingredient"&gt;Oil - 1-2 Tbsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;Whole Garam masala - Custom or readymade&lt;/li&gt;
  &lt;li class="ingredient"&gt;Salt - 3 Tsp.&lt;/li&gt;
  &lt;li class="ingredient"&gt;For Dum(Bringing together): Yogurt - 1/2 cup&lt;/li&gt;
  &lt;li class="ingredient"&gt;Saffron strands - dipped in milk, a few&lt;/li&gt;
  &lt;li class="ingredient"&gt;Chopped Nuts - As desired&lt;/li&gt;
  &lt;li class="ingredient"&gt;Mint and Coriander - two handfuls&lt;/li&gt;
  &lt;li class="ingredient"&gt;Fried onions - two handfuls&lt;/li&gt;
  &lt;li class="ingredient"&gt;Green chili - 4-5 slits&lt;/li&gt;
  &lt;li class="ingredient"&gt;Water - 1/4 cup&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class="ERInstructions"&gt;
  &lt;div class="ERInstructionsHeader"&gt;Instructions&lt;/div&gt;
  &lt;div class="instructions"&gt;
  &lt;ol&gt;
  &lt;li class="instruction"&gt;For Veggies: In a kadhai add oil. Now add whole garam masala, ginger-garlic paste. Saute for a minute. Now add carrot, potatoes, cauliflower, peas and salt. Saute until they are lightly cooked.&lt;/li&gt;
  &lt;li class="instruction"&gt;After the veggies are a bit cooked, add in biryani masala, red chili powder, garam masala powder and gradually add yogurt stirring well to prevent curdling of curd.&lt;/li&gt;
  &lt;li class="instruction"&gt;Now add mint, coriander, paneer. Cook until the moisture gets dried out which was caused due to adding yogurt. This would take approx 5 minutes. Veggies should not be cooked completely as we will dum it later on. It should 70% cooked.&lt;/li&gt;
  &lt;li class="instruction"&gt;After the moisture is dried, add some fried onions and transfer to a bowl.&lt;/li&gt;
  &lt;li class="instruction"&gt;For Rice: Boil water. Add oil, whole garam masala, salt. Boil until roaring boil. Add the soaked rice. In about 3-4 minutes in high flame rice will be 70% done. Test by eating some if it has a bite but its tastes like cooked or press between ur fingers. If breaks into 2 parts its ready. Strain it and spread on a big plate.&lt;/li&gt;
  &lt;li class="instruction"&gt;For Dum: Take a cooker, add half of the vegetables, yogurt, green chilli, a pinch of salt and some nuts. Let it heat. Now add a handful of mint coriander. Now top it off with a good layer of rice.&lt;/li&gt;
  &lt;li class="instruction"&gt;Next add the remaining vegetables, remaining mint-coriander(leave 1 tsp. for top), fried onions and the rice. Spread the rice and add the saffron mixture with a bit of mint-coriander, fried onion.&lt;/li&gt;
  &lt;li class="instruction"&gt;Now sprinkle 1/4 cup of water over it, Cover and cook for 2 minutes in lowest flame.&lt;/li&gt;
  &lt;li class="instruction"&gt;Transfer the cooker to a big pot with some water. This water bath prevents the dum to get burnt.. In about 30-35 minutes the Biryani is ready to make you dig into it.&lt;/li&gt;
  &lt;/ol&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="ERNutrition"&gt;&lt;/div&gt;
  &lt;div&gt;
  &lt;div class="ERNotesHeader"&gt;Notes&lt;/div&gt;
  &lt;div class="ERNotes"&gt;Cut vegetables in a uniform size.[br]Veggies are less, but the rice is used more for Biryanis.[br]You could use raw chopped nuts or saute them in oil and add.[br]Make sure to soak rice for atleast 1 hour.&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="endeasyrecipe" style="display: none;"&gt;3.2.1255&lt;/div&gt;
  &lt;/div&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  &lt;p&gt;&lt;a href="http://mywebsite.in.cp-25.webhostbox.net/wp-content/uploads/2013/09/Biryani-2.jpg"&gt;&lt;img class=" wp-image-411 alignright" alt="Biryani-2" src="http://mywebsite.in.cp-25.webhostbox.net/wp-content/uploads/2013/09/Biryani-2.jpg" width="189" height="142"&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;Recipe Ingredients are lengthy.. But it looks only onscreen.. Once you start preparing them they does not seem long or more.. Basic Ingredients, Easy Recipe and Traditional Hyderabadi Taste.. Dont forget to try it, I am sure you'll love it and make it again and again!!!&lt;/p&gt;
  &lt;p&gt;&lt;a href="http://www.youtube.com/mywebsite" target="_blank"&gt;Do Subscribe on YouTube&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;&lt;a href="http://www.fb.com/mywebsite" target="_blank"&gt;Like us on FB&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  &lt;p&gt;Video Recipe:&lt;/p&gt;
  &lt;p&gt;&lt;iframe src="//www.youtube.com/embed/zf0_AJfp5AA" height="500" width="835" allowfullscreen="" frameborder="0"&gt;&lt;/iframe&gt;&lt;/p&gt;
  </code></pre>