PLSQL String Searching

Submitted by code_admin on Mon, 07/30/2018 - 13:34

This code snippit demos how to search strings

  1. select
  2.     v,
  3.     substr(v,0,instr(v,'_')-1) as first_day,
  4.     substr(v,instr(v,'_',-1)+1) as last_day
  5. from (
  6.     select '0_32_23_34_324_34_0' as v from dual
  7.     union all select '1_32_23_34_324_34_0' as v from dual
  8.     union all select '1_32_23_34_324_34_1' as v from dual
  9.     union all select '0_32_23_34_324_34_1' as v from dual
  10.     union all select '0_0_0_0_0_0_0' as v from dual
  11.     union all select null as v from dual
  12.     union all select '' as v from dual
  13.     union all select ' ' as v from dual
  14.     union all select '_' as v from dual
  15.     union all select '_2_' as v from dual
  16.     union all select '2_' as v from dual
  17.     union all select '_2' as v from dual
  18.     union all select '__' as v from dual
  19.     union all select '___' as v from dual
  20.     union all select '____' as v from dual
  21. )

Tags

RJM Article Type
Quick Reference