Oracle PL/SQL:删除“空格字符"从一个字符串 [英] Oracle PL/SQL : remove "space characters" from a string

查看:117
本文介绍了Oracle PL/SQL:删除“空格字符"从一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Oracle 10g数据库中,我想从表字段的值中删除空格字符"(空格,制表符,回车...).

In my Oracle 10g database I would like to remove "space characters" (spaces, tabs, carriage returns...) from the values of a table field.

TRANSLATE()是要走的路吗?例如:

Is TRANSLATE() the way to go ? For example something like:

MY_VALUE := TRANSLATE(MY_VALUE,
  CHR(9) || CHR(10) || CHR(11) || CHR(12) || CHR(13) || ' ', '');

还是有更好的选择(例如PHP PCRE中的[:space:])?

Or is there any better alternative (something like [:space:] in PHP PCRE) ?

感谢您的任何建议.

推荐答案

我会去regexp_replace,尽管我不是100%地确定这在PL/SQL中可用

I'd go for regexp_replace, although I'm not 100% sure this is usable in PL/SQL

my_value := regexp_replace(my_value, '[[:space:]]*',''); 

这篇关于Oracle PL/SQL:删除“空格字符"从一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆