Introduction
Substring and overlay functions help you extract or replace parts of text easily, like cutting or pasting pieces of a string.
SUBSTRING(string FROM start FOR length) OVERLAY(string PLACING new_substring FROM start FOR length)
SELECT SUBSTRING('Hello World' FROM 1 FOR 5);
SELECT SUBSTRING('Hello World' FROM 7);
SELECT OVERLAY('Hello World' PLACING 'Friend' FROM 7 FOR 5);
SELECT OVERLAY('abcdef' PLACING '123' FROM 2 FOR 3);
SELECT 'Original text: Hello World' AS description; SELECT SUBSTRING('Hello World' FROM 1 FOR 5) AS substring_example; SELECT SUBSTRING('Hello World' FROM 7) AS substring_to_end; SELECT OVERLAY('Hello World' PLACING 'Friend' FROM 7 FOR 5) AS overlay_example; SELECT OVERLAY('abcdef' PLACING '123' FROM 2 FOR 3) AS overlay_partial;
substring function do when given a string and a start position?overlay function in PostgreSQL?SELECT overlay('abcdef' placing 'XYZ' from 2 for 3);SELECT overlay('hello' placing 'y' for 2 from 3);overlay and then extracts the substring starting at position 5 with length 4?Pass the test and this pattern moves unknown