`

replace和translate

    博客分类:
  • sql
 
阅读更多



REPLACE :
 replace function is:

replace( string1, string_to_replace, [ replacement_string ] )

string1 is the string to replace a sequence of characters with another set of characters.

string_to_replace is the string that will be searched for in string1.

replacement_string is optional. All occurrences of string_to_replace will be replaced with replacement_string in string1. If the replacement_string parameter is omitted, the replace function simply removes all occurrences of string_to_replace, and returns the resulting string

For example:
 

replace('123123tech', '123'); would return 'tech'
replace('123tech123', '123'); would return 'tech'
replace('222tech', '2', '3'); would return '333tech'

:: extact one to one matching of character string like '123' or 'abc'
   replacement character is not needed.




Translate :

translate( string1, string_to_replace, replacement_string )

 

string1 is the string to replace a sequence of characters with another set of characters.

string_to_replace is the string that will be searched for in string1.

replacement_string - All characters in the string_to_replace will be replaced with the corresponding character in the replacement_string.


For example:

translate('1tech23', '123', '456'); would return '4tech56'
translate('222tech', '2ec', '3it'); would return '333tith'


:: extact one to on e matching of character like 'a' or '1'
   replace character is needed
select translate('abc132fdsf','0123456789',' ') from dual;

 

 

-------

abcfdsf

或按以下方式

SQL> select translate('abc132fdsf','#0123456789','#') from dual;

 

-------

abcfdsf

--提取字符串中的数字,字母都被过滤,如下:

 

SQL> select translate('abc132fdsf','abcdefghigklmnopqrstuvwxyz',' ') from dual;

 

 

----

132
分享到:
评论

相关推荐

    ORACLE replace和translate函数详解

    ORACLE replace和translate函数详解

    Oracle 函数replace和translate的比较

    今天看了SQL COOKBOOK中的一个例子,其中看到了两个函数Replace和Translate时产生了疑惑,感觉这两个函数的作用是一样的,书上面的例子也看的不是很明白,Google了一下,看了Oracle的官方解释,终于彻底明白了。...

    Oracle中的translate函数和replace函数的用法详解

    translate返回expr,其中from_string中的每个字符的所有出现都被to_string中的相应字符替换,而replace 函数将char中的字符串search_string...下面给大家分享Oracle中的translate函数和replace函数的用法,一起看看吧

    ngx-translate-extract:提取可翻译的(使用ngx-translate)字符串并将其另存为JSON或Gettext pot文件

    如果此工具为您节省了时间,请考虑为持续的维护和发展捐款: :ngx-translate-extract 提取可翻译的(ngx-translate)字符串,并另存为JSON或Gettext pot文件。 如果输出文件已经存在,则与现有字符串合并。安装在您...

    Oracle Translate 统计字符出现的次数示例代码

    SELECT LENGTHB('ABCDEFGEFGDBE')-LENGTHB(REPLACE('ABCDEFGEFGDBE','E','')) FROM DUAL; Translate 的用法 一、语法:  TRANSLATE(string,from_str,to_str) 二、目的  返回将(所有出现的)from_str中的每个字符...

    ChatGPT论文提问(prompt)模板.docx

    I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. You should use artificial intelligence ...

    baidu-translate-ios-sdk:百度翻译 iOS SDK (非官方)

    说明 ... [BaiduTranslate setupBaiduClientKey:@"REPLACE ME WITH KEY"]; BTResultBlock callback = ^(TranslationEntity *translation, NSError *error) { if (!error) { if (translation) {

    逆向工程权威指南 英文版

    So just find filename_EN.tex file you want to translate, copy to filename_XX.tex (where XX is your language) and replace English text by yours. No special TeX/LaTeX knowledge is needed. Then just ...

    Oracle_Database_11g完全参考手册.part3/3

    8.5 REPLACE和REGEXPRRPIACE 第9章 数值处理 9.1 三类数值函数 9.2 表示法 9.3 单值函数 9.3.1 加减乘除 9.3.2 NULL 9.3.3 NVL:空值置换函数 9.3.4 ABS:绝对值函数 9.3.5 CEIL 9.3.6 FL00R 9.3.7 MOD 9.3.8 POWER...

    Oracle_Database_11g完全参考手册.part2/3

    8.5 REPLACE和REGEXPRRPIACE 第9章 数值处理 9.1 三类数值函数 9.2 表示法 9.3 单值函数 9.3.1 加减乘除 9.3.2 NULL 9.3.3 NVL:空值置换函数 9.3.4 ABS:绝对值函数 9.3.5 CEIL 9.3.6 FL00R 9.3.7 MOD 9.3.8 POWER...

    Visual_Studio_Package.vsix

    After adding the resource file, updating the extension, and translating the text (I’m a big fan of Google Translate for this part), you will need to remove the ‘Custom Tool’ property and make sure...

    删除电脑软件最好帮手

    Option to replace Add/Remove program (Uninstall Tool icon in Control Panel) Saving (exporting to HTML) detailed reports about currently installed applications Running "Windows Components" and "Add/...

    C# 访问Oracle示例+PL/SQL+存储过程+触发器 完整示例 测试可用 易懂

    select id,nvl(translate(translate(sex,1,'女'),0,'男'),'未知') from students; select id,case as 性别 from( select id,case sex when 1 then '女' when 0 then '男' else '未填' end case from students) temp...

    oracle使用管理笔记(一些经验的总结)

    Ⅰ.oracle itcast 1 1.oralce解锁步骤 2 2.oralce开发工具 3 3.oracle常用sql plus命令 4 4.oracle用户管理 5 (1)权限 5 (2)角色 5 ...(9)translate 75 (10)replace 76 (11)decode() 76 (12)nvl 77

    ChatGPT论文提问模板.zip

    will speak to you inany lanquage and you will detect the language, translate it and answer in the corrected and improvedversion of mytext, in English. You should use artificial intelligence tools, ...

    Linux shell tr 命令详解

    tr,translate的简写,主要用于压缩重复字符,删除文件中的控制字符以及进行字符转换操作。 2. 语法 tr [OPTION]... SET1 [SET2] 3. 参数 3.1 -s 压缩重复字符 -s: squeeze-repeats,用SET1指定的字符来替换对应...

    Functional Programming in R

    In Functional Programming in R, you’ll see how we can replace loops, which can have side-effects, with recursive functions that can more easily avoid them. In addition, the book covers why you ...

    Oracle自定义判断数据是否为数值函数

    1 CREATE OR REPLACE FUNCTION isnumeric (str IN VARCHAR2) 2 RETURN NUMBER 3 IS 4 v_str VARCHAR2 (1000); 5 BEGIN 6 IF str IS NULL 7 THEN 8 RETURN 0; 9 ELSE 10 v_str := translate(str, '....

    plug-In PHP- 100 Power Solutions

    Google Translate; Corner GIF; Rounded Table; Display Bing Map Real world solutions Plug-in PHP has everything you need for processing text; image uploading and manipulation; content management; ...

Global site tag (gtag.js) - Google Analytics