Insert value into field before and after specific string I need help with update function.

I have database table with three fields. One of them is code field with html div and script. 
Example:
&lt;div id='id1'&gt;&lt;/div&gt;&lt;script type="text/javascript"&gt;/* Banner */&lt;/script&gt;
My problem is, how am i supposed to insert some condition inside script tags and to end it before closing script tag? How should i write db_update to accomplish that?

Thanks in advance.
Sounds like you should be parsing the field with a regex function that matches the content between the script tags. Then you can rebuild your string and update the row.

http://regexr.com/3du5i for an example