0

我只需要替换数字并保留剩余部分。例子:

34HUNTAVE ==> 34THUNTAVE

1232432GRACE ST ==> 1232432NDGRACE ST

1232433GRACE ST ==> 1232433RDGRACE ST

问题是 Julian 格式在大数字上给出错误。我怎样才能使它工作。

   Does Not Work
    ------------
        SELECT REGEXP_REPLACE ('10425222GRACEST','[[:digit:]]+', 
         TO_CHAR (TO_DATE (REGEXP_REPLACE ('10425222GRACEST','[^[:digit:]]'),'J'),'fmJTH')) FROM dual;

     Works Fine
    ----------
         SELECT REGEXP_REPLACE ('10425BCST','[[:digit:]]+', 
         TO_CHAR (TO_DATE (REGEXP_REPLACE ('10425BCST','[^[:digit:]]'),'J'),'fmJTH')) FROM dual;
4

1 回答 1

2
select 
  string,
  regexp_substr(string, '^\D*\d+') ||
  regexp_substr(to_char(to_date(
    regexp_replace(string, '^\D*\d*?(\d{1,3})(\D|$).*$', '100\1'), 
    'J'), 'fmjth'), '\D*$') ||
  regexp_replace(string, '^\D*\d+(.*)$', '\1') as new_string
FROM your_table

小提琴

于 2013-03-12T04:05:05.317 回答