我需要帮助将数字替换为null。
示例:
输出:
答案 0 :(得分:1)
你可以用正则表达式完成它。例如,像这样:
WITH the_table AS (SELECT 'Dustun 0989 LLC' field FROM dual
UNION
SELECT 'Dustun_0989 LLC' field FROM dual
UNION
SELECT '457 Dustun LLC' field FROM dual
UNION
SELECT '457_Dustun LLC' field FROM dual
UNION
SELECT 'Dunlop 987' field FROM dual
UNION
SELECT '222 333 ADIS GROUP 422 123' field FROM dual)
SELECT field, TRIM(REGEXP_REPLACE(field,'((^|\s|\W)(\d|\s)+($|\s|\W))',' '))
FROM the_table
请注意,(^ | \ s | \ W)和($ | \ s | \ W)是等效于\ b的Oracle正则表达式,如Oracle REGEXP_LIKE and word boundaries中所述
其中:
答案 1 :(得分:0)
这里不需要PL / SQL,一个简单的SQL语句就可以了:
regexp_replace(the_column, '(\s[0-9]+\s)|(^[0-9]+\s)|(\s[0-9]+$)', ' ')
这会替换值开头的两个空格或数字之间的任意位数,后跟输入值末尾的空格或空格后面的数字。
以下内容:
with sample_data (the_column) as
(
select 'Dustun 0989 LLC' from dual union all
select 'Dustun_0989 LLC' from dual union all
select '457 Dustun LLC' from dual union all
select '457_Dustun LLC' from dual union all
select '334 Dunlop 987' from dual
)
select regexp_replace(the_column, '(\s[0-9]+\s)|(^[0-9]+\s)|(\s[0-9]+$)', ' ') as new_value
from sample_data
将输出:
NEW_VALUE
---------------
Dustun LLC
Dustun_0989 LLC
Dustun LLC
457_Dustun LLC
Dunlop
要删除前导(或尾随)空格,请使用trim
函数:trim(regexp_replace(...))
答案 2 :(得分:0)
这也会起作用
$scope.checkinput = function(keyevt){
if (keyevt.keyCode === 32 ) {
keyevt.returnValue = false;
return false;
}
}