String 如何在字符串中找到字符串并打印它?

String 如何在字符串中找到字符串并打印它?,string,oracle,String,Oracle,如何在字符串中打印字符串? 我有这样的行数据 城市名称 Abcde/def/Report_name/name 现在我只想打印报告名称后面的字符串 Abcde/def长度可能因生产线而异 报告名称/名称是标准命名格式 因此,我只想打印出现在/report\u名称之后的文本/ 对于这样的简单练习,最好学习,然后使用标准字符串函数、INSTR和SUBSTRinstr将在较长的字符串中查找正在搜索的子字符串的第一个字母的位置。因此,如果您搜索“Report\u names/”,您将找到R的位置。“名字”

如何在字符串中打印字符串? 我有这样的行数据

城市名称 Abcde/def/Report_name/name

现在我只想打印报告名称后面的字符串

  • Abcde/def长度可能因生产线而异
  • 报告名称/名称是标准命名格式
  • 因此,我只想打印出现在/report\u名称之后的文本/

  • 对于这样的简单练习,最好学习,然后使用标准字符串函数、
    INSTR
    SUBSTR
    instr
    将在较长的字符串中查找正在搜索的子字符串的第一个字母的位置。因此,如果您搜索
    “Report\u names/”
    ,您将找到
    R
    的位置。“名字”的第一个字母是它右边的13个位置。这将是您实际想要的子字符串的第一个字母,即“名称”。有了这些,您应该能够理解以下查询的作用:

    -- begin TEST DATA (not part of the solution to the problem)
    with
         test_data ( str ) as (
           select 'City_name Abcde/def/Report_names/Ann, Helen, Mary' from dual
         )
    -- end of TEST DATA; SQL query begins BELOW THIS LINE 
    -- use your actual table and column names instead of "test_data" and "str"
    select str, substr( str, instr(str, 'Report_names/') + 13 ) as names
    from   test_data
    ;
    
    STR                                                 NAMES
    -------------------------------------------------   --------------------
    City_name Abcde/def/Report_names/Ann, Helen, Mary   Ann, Helen, Mary
    
    1 row selected.
    

    在你提问之前,请展示你已经尝试了什么。我相信我们有很多例子
    从dual
    可能重复的@saikumarm中选择regexp_substr('City_name Abcde/def/Report_names/naxsusmes','Report_names/(.+)$',1,1,null,1)对于此类问题,最好在答案使用标准字符串函数而不是正则表达式的情况下查找类似问题。杀苍蝇不需要大炮。