여기에이 방법이 있습니다. 성능이 문제가되는 경우 중요 할 수있는 표준 문자열 함수를 사용합니다 (표준 함수는 정규 표현식 함수보다 훨씬 빠름).
그러나 'do-it-yourself'
문자열도 '000do-00it-yo'
으로 변환됩니다. 원하지 않는 경우 원래 게시물의 모든 규칙을 설명해야합니다.
with
inputs (str) as (
select '1111-2222-33' from dual union all
select '11111-222-33' from dual union all
select '11111-2222-3' from dual union all
select '1234-03-0' from dual
)
-- End of simulated inputs (for testing only, not part of the solution).
-- SQL query begins BELOW THIS LINE. Use your actual table and column names.
select str,
lpad(substr(str, 1, instr(str, '-') - 1), 5, '0') || '-' ||
lpad(substr(str, instr(str, '-') + 1,
instr(str, '-', 1, 2) - instr(str, '-') - 1), 4, '0')
|| '-' || lpad(substr(str, instr(str, '-', 1, 2) + 1), 2, '0') as new_str
from inputs
;
STR NEW_STR
------------ -------------
1111-2222-33 01111-2222-33
11111-222-33 11111-0222-33
11111-2222-3 11111-2222-03
1234-03-0-0003-00
요금은 어떻게 변경 했습니까? 그래서 코딩 서비스가 아닙니다 –
@ Teemani Afif 나는 당신을 얻지 못했습니다. –
[so] _free 코딩 _ 웹 사이트가 아닙니다. 지금까지 시도한 것과 노력한 것을 보여주세요. 문제 해결을 위해 노력하지만 ** 당신을 위해 코드를 작성하는 것은 아닙니다 **. 적절한 질문을하는 법을 배우기 위해 [둘러보기]를 읽고 [질문] 페이지를 읽어 보는 것이 좋습니다. – Shogunivar