The solution is for the Oracle DB, as it was not clear which DBMS the solution is being searched for
If width
is always after the img
tag, you can do that in the Oracle database with the Replace
function, for example
replace (<column>,'<img width="100%" ','<img ');
update statement could be like
update <table>
set <column> = replace (<column>,'<img width="100%" ','<img ')
If attribute width
does not come directly after the img
tag then you have to find the IMG
tag first. This can you do with a regular expression.
How to find the img tags was discussed here more than once.
check this question
This modified regular expression of the user sln could be useful to you:
<img\s[^>]*?(width\s*=\s*[''\"]([^''\"]*?)[''\"])([^>]*?)>
First, you have to find the img tags and filter out the information
replace(REGEXP_SUBSTR(txt,'<img\s[^>]*?width\s*=\s*[''\"]([^''\"]*?)[''\"][^>]*?>'),'width="100%" ','')
then you can replace the img tags with the filtered tags in the whole html, that could look like that:
REGEXP_REPLACE(txt
, '<img\s[^>]*?(width\s*=\s*[''\"]([^''\"]*?)[''\"])([^>]*?)>'
, replace(REGEXP_SUBSTR(txt,'<img\s[^>]*?width\s*=\s*[''\"]([^''\"]*?)[''\"][^>]*?>'),'width="100%" ','')
)
SQLFiddel Test
This may not be the optimal option, but it may be helpful