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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -