atmaweapon wrote:
> I'd like to make a "query replace" using regular expression in my records... Is it possible ?
> Something like this :
> UPDATE my_table SET myField="\1bar\2" WHERE myField="(.*)foo(.*)";
>
> I don't know if MySQL even permit this
MySQL regular expressions do not have this kind of functionality . They are match-only at present, returning either 1 (match) or 0 (no match).
However, depending on the complexity of your data, you might be able to use something like:
SET @a:= 'this is textfooand this is more text';
SELECT
SUBSTRING(@a, 1, INSTR(@a, 'foo')-1) AS '1',
SUBSTRING(@a, INSTR(@a, 'foo') + LENGTH('foo')) AS '2';
--
felix
Please use
BBCode to format your messages in this forum.