0

I have a question how to extract a substring.

Here an example string:

{{from,005021889988,,Amt},{setup-from,66,,},{alert-to,66,ConTeach Zentrale,ConTeach Zentrale},{conn-to,66,ConTeach Zentrale,ConTeach Zentrale},{transfer-to,10,kb,Kai Büsing},{conn-to,66,ConTeach Zentrale,ConTeach Zentrale {disc-to,,,},{rel-from,66,ConTeach Zentrale,ConTeach Zentrale}}

The goal is to extract '66,ConTeach Zentrale,ConTeach Zentrale' between '{conn-to,' and '},'

Any ideas?

asked Nov 16, 2018 at 13:17
1
  • 1
    what query(s) have you tried so far? I see 2x '{conn-to' snippets in your example string so how do you determine which one to extract? Commented Nov 16, 2018 at 14:45

1 Answer 1

1

You can use the function substring() with a regular expression. But you need to define your requirements exactly. Like markp commented, there is ambiguity with multiple matches.

SELECT substring($string FROM '{conn-to,(.*?)},')

The part between parentheses is returned. This returns the first match, and the non-greedy quantifier *? prefers the shortest match.

answered Nov 18, 2018 at 3:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.