ChatGPT VS SOUTH한국노말개발자
오늘 쿼리 정규식 추출을 해야하는데 갑자기 생각이 안남
간략하게 이런식임
'Zaa Oaa Taa' 앞에 대문자만 추출해야 하는데
퍼뜩 생각이 안나더이다!
그래서 ChatGpt 에 문의
'Zaa Oaa Taa' to 'ZOT'
oracle function regular expression use?
답변이
==============
One possible Oracle function that could use regular expressions to transform 'Zaa Oaa Taa' to 'ZOT' is the REGEXP_REPLACE function.
The syntax for using REGEXP_REPLACE to replace a pattern with a replacement string is:
REGEXP_REPLACE(input_string, regular_expression_pattern, replacement_string)
In this case, the regular expression pattern could be something like '\b([A-Za-z])\w+\s+([A-Za-z])\w+\s+([A-Za-z])\w+\b', .
................
The replacement string could simply be '\1\2\3', which replaces the matched pattern with the first letter of each word concatenated together.
So the full function call would look something like:
SELECT REGEXP_REPLACE('Zaa Oaa Taa', '\b([A-Za-z])\w+\s+([A-Za-z])\w+\s+([A-Za-z])\w+\b', '\1\2\3') FROM dual;
This would return 'ZOT' as the output.
==============
말이 참 많음
심지어 솔루션으로 나온 답이
SELECT REGEXP_REPLACE('Zaa Oaa Taa', '\b([A-Za-z])\w+\s+([A-Za-z])\w+\s+([A-Za-z])\w+\b', '\1\2\3') FROM dual;
을 실행해도 'Zaa Oaa Taa' 이게 나와버림... 틀림
흠.. 잠깐 쨰려보던 찰나에 "나는 봤다!"
SELECT REGEXP_REPLACE('Zaa Oaa Taa', 'a| ','') FROM dual
결과: ZOT
정확히 원하는 결과가 나옴.
이거슨!! 나의 승리
이러니 내가 억대 연봉자인거지.. ㅋㅋㅋ 캐 캬 커 크 흐 햐
가끔 ChatGPT랑 승부할텐데..
자신이 없네요.
질 자신이 ㅋㅋ
