2012-04-26 5 views
0

文字列の最後の数字を検索するにはどのようにしてreg式を使用しますか?c1の右辺と最後の数字のすべてを左+列c2に入る?PL/SQL Reg Exp最後の数値と分割が見つかりました

例えば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
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 
); 
+0

ありがとうございました。 – user1332821

関連する問題