sql - how to replace multiple words at once in postgresql -


to replace multiple words, i'm using looping thru candidates, , replacing 1 one. there better way?

create or replace function "myreplace"(text, _varchar, _varchar) returns "pg_catalog"."text"  $body$ declare     int;     result text; begin     result = $1;     in 1 .. array_length( $2, 1 ) loop         result = replace( result, $2[ ], $3[ ] );     end loop;      return result; end $body$ language 'plpgsql'; 

besides making stable , strict, , switching using pl/perl or c, there isn't optimization can make faster.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -