format string from given pattern

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pracheebapate
    New Member
    • Mar 2013
    • 1

    format string from given pattern

    hi everyone,

    i am trying to write postgresql query for below scenario:

    inputs :
    1. alphanumeric string e.g. abcd1234efgh
    2. pattern e.g. [1][2][3][2][1][3]
    3. delimiter e.g - (hyphen)

    output : a-bc-d12-34-e-fgh

    i require query. function wont work for me.

    any help is welcome.

    thanks
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    If you are saying that the pattern and delimiter won't change. You can use a series of substrings to get the output. If, however, it is variable, you will have to use a function, I don't see any way around that.

    Comment

    Working...