如何使用reg表达式找到字符串中的最后一个数字,然后右侧的所有内容进入c1列,最后一个数字左边的所有内容+ 1个字符进入c2列?
例如1
string = 1234john4345 this is a test.
结果
c1 = 1234john4345
c2 = this is a test.
例如2
string = 1234john4345a this is a test.
结果
c1 = 1234john4345a
c2 = this is a test.
答案 0 :(得分:0)
select test
--Group 1: Match everything up to the last digit, and one other character
--Group 2: Everything after group 1
,regexp_replace(test, '(.*[[:digit:]].)(.*)', '\1') c1
,regexp_replace(test, '(.*[[:digit:]].)(.*)', '\2') c2
from
(
select '1234john4345 this is a test.' test from dual union all
select '1234john4345a this is a test' test from dual
);