Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Oracle Question: Split String into two

Oracle Question: Split String into two

Scheduled Pinned Locked Moved Database
questionoraclehelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lash20
    wrote on last edited by
    #1

    Hi all, How do you use the REGEXP_SUBSTR function to split a string into two? Specifically, I want to split a string into two where " and " is the delimiter (note the whitespace). So for example, if the string is "xande and zem and dem and doe", I want string 1 to be "xande" and string 2 to be "zem and dem and doe". Any help would be greatly appreciated. Thanks

    J 1 Reply Last reply
    0
    • L Lash20

      Hi all, How do you use the REGEXP_SUBSTR function to split a string into two? Specifically, I want to split a string into two where " and " is the delimiter (note the whitespace). So for example, if the string is "xande and zem and dem and doe", I want string 1 to be "xande" and string 2 to be "zem and dem and doe". Any help would be greatly appreciated. Thanks

      J Offline
      J Offline
      Jorgen Andersson
      wrote on last edited by
      #2

      case
      when instr(mystring, ' and ') > 0 then substr(mystring, 0, instr(mystring, ' and ')-1)
      else mystring
      end as string1
      case
      when instr(mystring, ' and ') > 0 then substr(mystring, instr(mystring, ' and ') + length(' and '))
      else null
      end as string2

      Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

      L 1 Reply Last reply
      0
      • J Jorgen Andersson

        case
        when instr(mystring, ' and ') > 0 then substr(mystring, 0, instr(mystring, ' and ')-1)
        else mystring
        end as string1
        case
        when instr(mystring, ' and ') > 0 then substr(mystring, instr(mystring, ' and ') + length(' and '))
        else null
        end as string2

        Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

        L Offline
        L Offline
        Lash20
        wrote on last edited by
        #3

        Worked perfectly. Thanks Jorgen!

        J 1 Reply Last reply
        0
        • L Lash20

          Worked perfectly. Thanks Jorgen!

          J Offline
          J Offline
          Jorgen Andersson
          wrote on last edited by
          #4

          You're welcome

          Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups