with t as ( select 'starlits@adminschool.net' as email from dual ) SELECT email ,REGEXP_SUBSTR(email, '[^@]+', 1, 1) AS "ID" ,REGEXP_SUBSTR(email, '[^@]+', 1, 2) AS "MailAddr" FROM t ;
EMAIL ID MailAddr ------------------------ ------------------------ ------------------------ starlits@adminschool.net starlits adminschool.net
SELECT STUDYUNITCODE, REGEXP_SUBSTR(REGEXP_REPLACE(STUDYUNITCODE,'^0',''),'[[:digit:]]{1,2}') TAPE, REGEXP_SUBSTR(STUDYUNITCODE,'[[:alpha:]]{1}') SIDE FROM TB_STUDYUNIT ORDER BY KWON,STUDYUNITCODE
STUDYUNITCODE TAPE SIDE 01A 1 A 10B 10 B 12A 12 A 02B 2 B 23A 23 A 30B 30 B
with t as ( select '01AB' tape from dual union all select '01BA' tape from dual ) select regexp_replace(tape, '[[:digit:]]','') from t;
TAPE SIDE -------------- 01AB AB 01BA BA
with t as ( select '01AB' tape from dual union all select '01BA' tape from dual ) select regexp_replace(tape, '[^[:digit:]]','') from t;
TAPE SIDE -------------- 01AB 01 01BA 01
SELECT SOURCE, REPLACE(REGEXP_SUBSTR(SOURCE,'p[[:digit:]]{1,3}'),'p','') PAGE FROM QUESTION WHERE ROWNUM < 10;
SOURCE PAGE b1: p24 24 b1: p19, 24, 32, 46 19 b3: p5 5 b3: p29 29 b3: p10-11 10 b2: p22 22 b1: p20 b2: p15 b4: p40 20 b2: p8-9, 30 8 b3: p16-17 16
SELECT ADDRESS ,REGEXP_SUBSTR(ADDRESS,'[^ ]+') AS SIDO ,REPLACE(REGEXP_SUBSTR(ADDRESS,' +[^ ]+'),' ','') AS GUGUN ,REPLACE(ADDRESS,REGEXP_SUBSTR(ADDRESS,'[^ ]+')||REGEXP_SUBSTR(ADDRESS,' +[^ ]+')||' ','') AS etc ,REGEXP_SUBSTR(ADDRESS,'[^ ]+(.)$') FROM DV_ADDRESS_TEMP ;
address | sido | gugun | remain | etc |
---|---|---|---|---|
충남 청양군 청양읍 읍내리 175-21 | 충남 | 청양군 | 청양읍 읍내리 175-21 | 175-21 |
충남 청양군 읍내리 209-3 | 충남 | 청양군 | 읍내리 209-3 | 209-3 |
충남 태안군 태안읍 동문리 529-2 | 충남 | 태안군 | 태안읍 동문리 529-2 | 529-2 |
충남 태안군 태안읍 동문리 879-3 | 충남 | 태안군 | 태안읍 동문리 879-3 | 879-3 |
WITH tt AS ( SELECT '147[1]36126[2]37980[3]2047627[4]1207745[5]' AS str FROM dual ) SELECT REGEXP_SUBSTR(str,'[0-9]+',1,1) AS a1 ,REGEXP_SUBSTR(str,'[0-9]+',1,2) AS a2 ,REGEXP_SUBSTR(str,'[0-9]+',1,3) AS a3 FROM tt;
A1 A A3 --- - ----- 147 1 36126
WITH v_time AS ( SELECT '2016. 1. 29. 오후 11:00:53' AS TIME FROM dual ) SELECT TIME ,REGEXP_SUBSTR(TIME,'[^ ]+',1,1,'i') || REGEXP_SUBSTR(TIME,'[^ ]+',1,2,'i') || REGEXP_SUBSTR(TIME,'[^ ]+',1,3,'i') AS ymd ,TO_DATE(REGEXP_SUBSTR(TIME,'[^ ]+',1,1,'i') || REGEXP_SUBSTR(TIME,'[^ ]+',1,2,'i') || REGEXP_SUBSTR(TIME,'[^ ]+',1,3,'i'),'YYYY.fmMM.DD.') AS convert_time FROM v_time;
TIME YMD CONVERT_TIME ------------------------ --------------- ------------------- 2016. 1. 29. 오후 11:00:53 2016.1.29. 2016-01-29 00:00:00
WITH cust AS ( SELECT '010-1234-5678' AS phone FROM dual ) SELECT REGEXP_SUBSTR(phone, '[^-]+', 1, 1) AS str1 , REGEXP_SUBSTR(phone, '[^-]+', 1, 2) AS str2 , REGEXP_SUBSTR(phone, '[^-]+', 1, 3) AS str3 , REGEXP_SUBSTR(phone, '[^-]+$', 1, 1) AS last_str FROM cust;
STR STR2 STR3 LAST_STR --- ---- ---- ---- 010 1234 5678 5678
WITH cust AS ( SELECT '010-1234-5678' AS phone FROM dual ) SELECT substr(phone,-4,4) AS str FROM cust;
SELECT REGEXP_SUBSTR('first-team second-team third-team', '[[:alnum:]]*') FROM dual;
first
SELECT REGEXP_SUBSTR('first-team second-team third-team', '[^ ]+') FROM dual;
first-team