zoukankan      html  css  js  c++  java
  • 截取字符(substr)检索字符位置(instr)

    1.SUBSTR(string,start_position,[length]) 求子字符串,返回字符串
    注释:

    string 元字符串
    start_position 开始位置(从0开始)
    length 可选项,子字符串的个数


    For example:

    substr("ABCDEFG", 0); //返回:ABCDEFG,截取所有字符
    substr("ABCDEFG", 2); //返回:CDEFG,截取从C开始之后所有字符
    substr("ABCDEFG", 0, 3); //返回:ABC,截取从A开始3个字符
    substr("ABCDEFG", 0, 100); //返回:ABCDEFG,100虽然超出预处理的字符串最长度,但不会影响返回结果,系统按预处理字符串最大数量返回。
    substr("ABCDEFG", -3); //返回:EFG,注意参数-3,为负值时表示从尾部开始算起,字符串排列位置不变。

    2.INSTR(string,subString,position,ocurrence)查找字符串位置
    注释:
    string:源字符串
    subString:要查找的子字符串
    position:查找的开始位置
    ocurrence:源字符串中第几次出现的子字符串
    For example:
    INSTR('CORPORATE FLOOR','OR', 3, 2)中,源字符串为'CORPORATE FLOOR', 目标字符串为'OR',起始位置为3,取第2个匹配项的位置;返回结果为 14 '

    select substr('OR:com.lcs.wc.placeholder.Placeholder:860825',INSTR('OR:com.lcs.wc.placeholder.Placeholder:860825',':', 1, 2)+1,length('OR:com.lcs.wc.placeholder.Placeholder:860825'))
    ,INSTR('OR:com.lcs.wc.placeholder.Placeholder:860825',':', 1, 2),
    length('OR:com.lcs.wc.placeholder.Placeholder:860825') From dual;

  • 相关阅读:
    java 多线程 合并多个查询结果
    Nginx + Tomat https ssl 部署方案
    ActiveMQ 简单介绍以及安装
    Redis 基础使用 及 队列、订阅
    RPC远程调用 之 Hessian
    SpringBoot 整合 Swagger2 以及 Swagger2 常用使用
    Mysql 优化
    JVM性能调优
    超实用压力测试工具-ab工具
    easypoi 快速开发 导出 各种姿势的excel
  • 原文地址:https://www.cnblogs.com/xiaohuihui123/p/5355320.html
Copyright © 2011-2022 走看看