on-internet
โ† Community

Replace multiple different substrings in one pass

Stack Overflow ยท

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

Comments

Sign in or sign up to comment and upvote.

No comments yet.