본 포스팅은 빅쿼리 자주 사용하는 정규표현식을 정리한 문서입니다. 필요하면 여기서 복사해서 쿼리에 붙여넣기!
(*주의) 본 정규식은 정답이 아닙니다. 시간에 따라 그 쓰임이 달라질 수 있기 때문에, 사용자 본인의 목적에 맞추어 수정해서 사용하시면 됩니다.
re2
regexp_extract_all('내 이름은 이인영이고, 내 이메일주소는 2innnnn0@kakao.com이다.', '[\\w\\.]+@[\\w\\.]+[A-Za-z]+') as email
예외조건을 추가하면 다음과 같다.
[\\w[:punct:]]+@[\\w[:punct:]]+[A-Za-z]+
regexp_extract_all('010-1234-5678', '[\\d]{3,4}-[\\d]{3,4}-[\\d]{4}') as phone
00가0000
(숫자 2자리+한글+숫자 4자리) 형태지만, 000가0000
처럼 2019-09 기준으로 앞자리가 3자리인 번호판이 등장했다.regexp_extract_all('차랑번호: 12하1234, 123하1234, 과태료 5만원 부과대상입니다.' , '([0-9]{2,3}[가-힣]{1}\\s{0,1}[0-9]{4})') as license_plate,
"https://www.example.com/video/detail?id=001" as url,
regexp_extract_all("https://www.example.com/video/detail?id=001", "//[^/]+([^?#]+)") as path,
regexp_extract_all("https://www.example.com/video/detail?id=001", "id=[^&]*") as id
(참고:우아한형제들 테크블로그) https://woowabros.github.io/study/2016/08/16/easy_and_fun_reg_exp.html
regexp_extract_all('서울특별시 광진구 자양동 256-12', '[가-힣]+[시|도]') as region1, #시/도
regexp_extract_all('서울특별시 광진구 자양동 256-12', '\\s[가-힣]+[시|군|구]') as region2, #시/군/구
regexp_extract_all('서울특별시 광진구 자양동 256-12', '\\s[가-힣]+[읍|면|동|가|리]\\s[\\d]{1,5}[-][\\d]{1,5}') as region3 #읍/동/면/
'[0-9]{2}[.][0-9]+[,][0-9]{3}[.][0-9]+'
regexp_extract_all('https://www.google.com/maps/place/@37.5305705,127.080649,15.5z/', '[0-9]{2}[.][0-9]+[,][0-9]{3}[.][0-9]+') as geo
WITH
memo_t AS (
SELECT
'''차량번호 : 10호1234
연락처 : 010-1234-5678
이름 : 홍길동
이메일 : 2innnnn0@kakao.com
주소 : 서울특별시 광진구 자양동 256-12
URL : https://velog.io/@2innnnn0/Bigquery-GIS-g5yojur6''' AS memo )
SELECT
REGEXP_EXTRACT_ALL(memo, '[\\w\\.]+@[\\w\\.]+[A-Za-z]+') AS email,
REGEXP_EXTRACT_ALL(memo, '[\\d]{3,4}-[\\d]{3,4}-[\\d]{4}') AS phone,
REGEXP_EXTRACT_ALL(memo, '([0-9]{2,3}[가-힣]{1}\\s{0,1}[0-9]{4})') AS license_plate,
REGEXP_EXTRACT_ALL(memo, "//[^/]+([^?#]+)") AS url_path,
FROM
memo_t
(EOD)
깔끔하게 정리되어 있네요!
덕분에 궁금증 해결하고 갑니다!
감사합니다 : )