given the text string
foo.bar.baz
how do I use split_part function of postgresql to get the rest after the first dot?
I want to extract from this text the next 2 texts:
foo
bar.baz
split_part requires number of part as argument so
split_part('foo.bar.baz', ''.', 2);
returns
bar
but not bar.baz
how do I get this using this function, or any other available function?
Thanks
I would probably use the regex form of substring:
substring('foo.bar.baz' from E'[^.]*\\.(.+)$')
This matches any number of non-. characters, then a dot, then any number of characters. Because the last part is in brackets it is captured and returned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With