concat_instr_replace
2008-11-19 19:47
27 查看
字符串函数
1,concat(str1,str2) 链接两个字符串
例:select concat('ni','hao') nr from dual
结果
nr
nihao
与语句select 'ni'||'hao' nr from dual 等效
2,instr(c1,c2,i,j)在一个字符串中搜索指定的字符,返回发现指定的字符的位置
c1:被搜索的字符串
c2:指定搜索的字符
i: 搜索开始位置,默认为1
j: 出现的位置,默认为1
例:select instr('oracle traning','ra',1,2) wz from dual
结果
wz
9
3,replace(str,str1,str2)
str:要替换的字符或变量
str1:被替换的字符串
str2:用来替换的字符串
例:select replace('oracle traning','oracle','java') nr from dual
结果
nr
java traning
------------复杂实例
替换oracle traning
1,如果替换所有ra
replace('oracle traning','ra','#')
2,替换第二个ra
取第2个ra的位置,instr('oracle traning','ra',1,2) =9
截取第2个ra字符,
substr('oracle traning',instr('oracle traning','ra',1,2),2)
替换第2个ra字符,
replace(substr('oracle traning',instr('oracle traning','ra',1,2),2),'ra','#')
取没有替换的字符串,
substr('oracle traning',1,instr('oracle traning','ra',1,2)-1)
substr('oracle traning',instr('oracle traning','ra',1,2)+2,length('oracle traning')-10)
联结字符:
substr('oracle traning',1,instr('oracle traning','ra',1,2)-1)||replace(substr('oracle traning',instr('oracle traning','ra',1,2),2),'ra','#')||substr('oracle traning',instr('oracle traning','ra',1,2)+2,length('oracle traning')-10)
1,concat(str1,str2) 链接两个字符串
例:select concat('ni','hao') nr from dual
结果
nr
nihao
与语句select 'ni'||'hao' nr from dual 等效
2,instr(c1,c2,i,j)在一个字符串中搜索指定的字符,返回发现指定的字符的位置
c1:被搜索的字符串
c2:指定搜索的字符
i: 搜索开始位置,默认为1
j: 出现的位置,默认为1
例:select instr('oracle traning','ra',1,2) wz from dual
结果
wz
9
3,replace(str,str1,str2)
str:要替换的字符或变量
str1:被替换的字符串
str2:用来替换的字符串
例:select replace('oracle traning','oracle','java') nr from dual
结果
nr
java traning
------------复杂实例
替换oracle traning
1,如果替换所有ra
replace('oracle traning','ra','#')
2,替换第二个ra
取第2个ra的位置,instr('oracle traning','ra',1,2) =9
截取第2个ra字符,
substr('oracle traning',instr('oracle traning','ra',1,2),2)
替换第2个ra字符,
replace(substr('oracle traning',instr('oracle traning','ra',1,2),2),'ra','#')
取没有替换的字符串,
substr('oracle traning',1,instr('oracle traning','ra',1,2)-1)
substr('oracle traning',instr('oracle traning','ra',1,2)+2,length('oracle traning')-10)
联结字符:
substr('oracle traning',1,instr('oracle traning','ra',1,2)-1)||replace(substr('oracle traning',instr('oracle traning','ra',1,2),2),'ra','#')||substr('oracle traning',instr('oracle traning','ra',1,2)+2,length('oracle traning')-10)
相关文章推荐
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
- javascript字符串string常用的几种方法(indexOf/lastIndexOf/search/charAt/match/slice/substr/replace/concat/split
- oracle中实现截取字符串(substr)、查找字符串位置(instr)、替换字符串(replace)
- oracle中实现截取字符串(substr)、查找字符串位置(instr)、替换字符串(replace)
- mysql中的replace,concat,cast等等字符串函数
- Oracle常用函数:nvl/nullif/case when/wm_concat/replace
- Oracle截取字符串substr、查找字符串位置instr、替换字符串replace
- replace与regexp_replace区别使用以及like与instr差异
- Oracle正则表达式之 Regexp_substr,Regexp_instr,Regexp_replace,Regexp_like
- javascript-string类型的方法(match,replace,split,concat+join)
- Oracle字符串操作函数(CONCAT,REPLACE,SUBSTR ....)
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace(转载保存一下)
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
- Oracle正规则函数的用法,regexp_substr,REGEXP_LIKE,REGEXP_INSTR,REGEXP_REPLACE
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
- Oracle 常用函数:nvl/nullif/case when/wm_concat/replace
- Oracle中CONCAT,SUBSTR,REPLACE的实例介绍