删除字符串中的所有空格

问题描述 投票:1回答:3

我必须删除String '5 000 000,5' to '5000000,5'中的所有空格。

我在下面尝试了3但它没有用

select replace('5 000 000,5',' ','') from dual; 
select regexp_replace('5 000 000,5', '[[:space:]]*','') from dual;
select regexp_replace('5 000 000,5', ' ','') from dual;

或者任何人都知道如何将此字符串'5 000 000,5'转换为数字,因为TO_NUMBER失败。谢谢

sql oracle removing-whitespace
3个回答
3
投票
  1. 使用REGEXP_REPLACESPACE类。

Select regexp_replace('your_value', '[[:space:]]+', '') from dual:

  1. 使用REPLACE

Select REPLACE('your_value', chr(32), '') from dual:


2
投票

我认为问题是你的NLS_NUMERIC_CHARACTERS,它应该可行

select to_number('5 000 000,5', '9G999G999D0', 'NLS_NUMERIC_CHARACTERS = '', ''')
from dual

2
投票

你可以尝试这个并删除任何非数字字符,如逗号(,

SELECT  to_number(regexp_replace('5 000 000,5', '[^0-9]', '')) FROM    dual;
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.