0

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.
4

1 に答える 1

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
);
于 2012-04-26T04:48:16.883 に答える