반응형
regexp_substr Maria가 있는 문자열에서 마지막 날짜를 추출하려면 어떻게 해야 합니까?DB
regexp_substr이 있는 문자열에서 마지막 날짜를 추출하려고 합니다.
어떻게 하면 되죠?
select regexp_substr('08.09.11 some text around
10.10.13 AP ab 16.10.13 some text around
13.08.2014 some text around.
01.09.2014 some text around
07.11.2014 some text. around
10.02.15 some text. around
11.02.15 some text around . (tp)',
'[0-9]+.[0-9]+.[0-9]+') as test
저의 실제 결과는 첫번째 날짜(08.09.11)입니다.
정말 고마워.
여기서 한 가지 방법은 사용하는 것입니다.REGEXP_REPLACE
캡처 그룹과 함께:
SELECT REGEXP_REPLACE('08.09.11 some text around
10.10.13 AP ab 16.10.13 some text around
13.08.2014 some text around.
01.09.2014 some text around
07.11.2014 some text. around
10.02.15 some text. around
11.02.15 some text around . (tp)',
'^[\\s\\S]*\\s(\\d+\.\\d+\.\\d+)[\\s\\S]*$',
'\\1') AS test
데모
다음은 사용된 regex 패턴에 대한 설명입니다.
^ from the start of the input
[\\s\\S]* match all content, across newlines
\\s until reaching the LAST whitespace
(\\d+\.\\d+\.\\d+) which is followed by the last date
(and capture this date in \1)
[\\s\\S]* consume remainder of input
$ end of the input
언급URL : https://stackoverflow.com/questions/66105009/how-can-i-extract-last-date-from-a-string-with-regexp-substr-mariadb
반응형
'it-source' 카테고리의 다른 글
32비트 응용 프로그램은 64비트 Linux에서 시스템 호출을 어떻게 합니까? (0) | 2023.10.28 |
---|---|
셀러리 없는 장고에서의 백그라운드 처리 (0) | 2023.10.28 |
JQuery는 다른 자바스크립트에서 AJAX 호출을 들을 수 있습니까? (0) | 2023.10.28 |
구조체에 대한 모든 포인터가 동일한 크기여야 하는 이유는 무엇입니까? (0) | 2023.10.28 |
ASP.NET jQuery Ajax 호출 코드 비하인드 메서드 (0) | 2023.10.28 |