oracle function

//首字母大写
INITCAP('tech on the net');
result:'Tech On The Net'
//删除左边匹配的内容,第二个参数为空的话则为匹配删除空格
LTRIM('123123Tech', '123')
Result: 'Tech'
LTRIM( '637Tech', '0123456789')
Result: 'Tech'
//删除右边匹配的内容,第二个参数为空的话则为匹配删除空格
RTRIM('tech   ')
Result: 'tech'
RTRIM('Tech123123', '123')
Result: 'Tech'
//trim
TRIM('   tech   ')
Result: 'tech'
TRIM(' '  FROM  '   tech   ')
Result: 'tech'
TRIM(LEADING '0' FROM '000123')
Result: '123'
TRIM(TRAILING '1' FROM 'Tech1')
Result: 'Tech'
TRIM(BOTH '1' FROM '123Tech111')
Result: '23Tech'
//replace
REPLACE('123123tech', '123');
Result: 'tech'
REPLACE('123tech123', '123');
Result:'tech'
REPLACE('222tech', '2', '3');
Result: '333tech'
REPLACE('0000123', '0');
Result: '123'
REPLACE('0000123', '0', ' ');
Result: '    123'
//SUBSTR  (start 为负数时,就是倒数第几个)
SUBSTR('This is a test', 6, 2)
Result: 'is'
SUBSTR('This is a test', 6)
Result: 'is a test'
SUBSTR('TechOnTheNet', 1, 4)
Result: 'Tech'
SUBSTR('TechOnTheNet', -3, 3)
Result: 'Net'
SUBSTR('TechOnTheNet', -6, 3)
Result: 'The'
SUBSTR('TechOnTheNet', -8, 2)
Result: 'On'
//function REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)
//__srcstr     :需要进行正则处理的字符串
//__pattern    :进行匹配的正则表达式
//__position   :起始位置,从第几个字符开始正则表达式匹配(默认为1)
//__occurrence :标识第几个匹配组,默认为1
//__modifier   :模式('i'不区分大小写进行检索;'c'区分大小写进行检索。默认为'c'。)
SELECT REGEXP_SUBSTR ('TechOnTheNet is a great resource', '(\S*)(\s)')
FROM dual;
Result: 'TechOnTheNet '
SELECT REGEXP_SUBSTR ('TechOnTheNet is a great resource', '(\S*)')
FROM dual;

Result: 'TechOnTheNet'
SELECT REGEXP_SUBSTR ('TechOnTheNet is a great resource', '(\S*)(\s)', 1, 2)
FROM dual;

Result: 'is '
SELECT REGEXP_SUBSTR ('2, 5, and 10 are numbers in this example', '\d')
FROM dual;

Result: 2
SELECT REGEXP_SUBSTR ('2, 5, and 10 are numbers in this example', '(\d)(\d)')
FROM dual;

Result: 10
SELECT REGEXP_SUBSTR ('Anderson', 'a|e|i|o|u', 1, 1, 'i')
FROM dual;

Result: 'A'
SELECT REGEXP_SUBSTR ('TechOnTheNet is a great resource', '(\S*)(\s)', 1, 3)
FROM dual

SELECT REGEXP_SUBSTR ('TechOnTheNet', 'a|e|i|o|u', 1, 3, 'i')
FROM dual;
//INSTR( string, substring [, start_position [,  nth_appearance ] ] )
INSTR('Tech on the net', 'e')
Result: 2   (the first occurrence of 'e')

INSTR('Tech on the net', 'e', 1, 1)
Result: 2   (the first occurrence of 'e')

INSTR('Tech on the net', 'e', 1, 2)
Result: 11  (the 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值