DEV Community

Discussion on: Daily Challenge #1 - String Peeler

Collapse
 
rafi993 profile image
Rafi • Edited

solution in SQL (postgres)

\set str 'hello world'

select (
     case
       when (select length(:'str') > 2) 
        then (select substr(:'str', 2, length(:'str') - 2) ) 
else 'invalid string' end );