I have several strings like this:
1:723:NVDA:NSDQ::Z4189274321:Snapshot Report:10:COMPUTER & TECHNOLOGY:241:Semiconductor
Basically I need to return everything after the second colon :. So, from the above string I really just need:
NVDA:NSDQ::Z4189274321:Snapshot Report:10:COMPUTER & TECHNOLOGY:241:Semiconductor
Seeing lots of examples, but none are really working for this task.
Many thanks!
2
Answers
This uses
string_to_array
from here:https://www.postgresql.org/docs/current/functions-string.html
This breaks the string down into it’s component parts and makes an array out of them. The
[3:]
selects the third through the end of the array elements from the array.Then from here:
https://www.postgresql.org/docs/current/functions-array.html
This reconstitutes the string by concatenating the array elements with the delimiter.
This one returns an array, by splitting the content on the :
If you need a single string:
This one uses a regex to split the content and also returns an array, but just one element and that’s easy to convert to a single string: