0

我有以下字符串,用逗号和“;”分隔 必须反转由“;”分隔的所有字符串的逗号分隔值。

例子:

-7.820420745913251,-38.221914235592905;-7.838209448558699,-38.206725420257172;-7.90608019095979,-38.238334576496392;-7.905396010088811,-38.163485189211315;-7.929205504398873,-38.168137619133972;-7.940015562160337,-38.155001346411183;-7.940973415379707,-38.154590837888591;-7.941520760076489,-38.154180329366007;

结果:

-38.221914235592905,-7.820420745913251;-38.206725420257172,-7.838209448558699;...

请帮帮我!!

4

1 回答 1

1

尝试这个:

SELECT regexp_replace(
'-7.820420745913251,-38.221914235592905;-7.838209448558699,-38.206725420257172;-7.90608019095979,-38.238334576496392;-7.905396010088811,-38.163485189211315;-7.929205504398873,-38.168137619133972;-7.940015562160337,-38.155001346411183;-7.940973415379707,-38.154590837888591;-7.941520760076489,-38.154180329366007;',
'([^,]*),([^;]*);','\2,\1;') RESULT
  FROM dual;

RESULT
--------------------------------------------------------------------------------
-38.221914235592905,-7.820420745913251;-38.206725420257172,-7.838209448558699;-38.238334576496392,-7.90608019095979;-38.163485189211315,-7.905396010088811;-38.168137619133972,-7.929205504398873;-38.155001346411183,-7.940015562160337;-38.154590837888591,-7.940973415379707;-38.154180329366007,-7.941520760076489;

有关详细信息,请参阅REGEXP_REPLACE 文档

于 2013-09-30T14:57:07.390 回答