mysql - Update a string using regular expressions in SQL -


i have string in columns of database:

<img title="\frac{3}{8}" src="http://latex.codecogs.com/gif.latex?\dpi{50}&amp;space;\fn_phv&amp;space;\frac{3}{8}" alt="" /> 

basically contains html code fraction. replace with:

<sup>3</sup>&frasl;<sub>8</sub> 

i know can update value in database such:

update table  set `field` = replace(`option`, '<img title="\frac{3}{8}" src="http://latex.codecogs.com/gif.latex?\dpi{50}&amp;space;\fn_phv&amp;space;\frac{3}{8}" alt="" />','<sup>3</sup>&frasl;<sub>8</sub>') `filed`  '%<img title="\frac{3}{8}" src="http://latex.codecogs.com/gif.latex?\dpi{50}&amp;space;\fn_phv&amp;space;\frac{3}{8}" alt="" />%' 

however, word "\frac{3}{8}" can change accordingly. number in parentheses can change , when changes need change html tag replace change accordingly well. know need use regular expressions, not sure how in sql.

need guidance it.

why update table? why have stored in table?

it seems application code (php?) construct string:

$numerator = 3; $denominator = 8; $img = "<img       title="\frac{$numerator}{$denominator}"       src=\"http://latex.codecogs.com/gif.latex?\dpi{50}&amp;             space;\fn_phv&amp;space;\frac{$numerator}{$denominator}\"       alt=''       />"; 

(etc)

there no regexp_replace, except in mariadb.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -