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}&space;\fn_phv&space;\frac{3}{8}" alt="" />
basically contains html code fraction. replace with:
<sup>3</sup>⁄<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}&space;\fn_phv&space;\frac{3}{8}" alt="" />','<sup>3</sup>⁄<sub>8</sub>') `filed` '%<img title="\frac{3}{8}" src="http://latex.codecogs.com/gif.latex?\dpi{50}&space;\fn_phv&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}& space;\fn_phv&space;\frac{$numerator}{$denominator}\" alt='' />";
(etc)
there no regexp_replace
, except in mariadb.
Comments
Post a Comment