Replace multiple different substrings in one pass
I am searching for a SQL approach to replace multiple different multi-character substrings for an arbitrary string. Example replacements: 1. Hello -> Hi 2. World -> Universe 3. dog -> ๐ 4. fox -> ๐ฆ 5. duck -> ๐ฆ 6. swan -> ๐ฆข They should be applied in a specific order. For sample data: CREATE TABLE replacements(i INT, s1 TEXT, s2 TEXT); INSERT INTO replacements(i, s1, s2) VALUES (1, 'Hello', 'Hi'), (2, 'World', 'Universe'), (3, 'dog','๐'), (4 ,'fox','๐ฆ'), (5 ,'duck','๐ฆ'), (6 ,'swan', '๐ฆข'); CREATE TABLE tab(col STRING); INSERT INTO tab(col) VALUES ('Hello World!') ,('The quick brown fox jumps ove
0 upvotes
View original discussion โ
Comments
Sign in or sign up to comment and upvote.
No comments yet.