I would like to find an elegant way to emulate the behavior of MySQL\'s subtring_index() function in Postgres.
In MySQL, it\'s as easy as:
mysql>
Always take the time to skim the manuals.
http://www.postgresql.org/docs/current/static/functions-string.html
If split_part(string text, delimiter text, field int) doesn't do what you want (and more, if I understand your MySQL function) then you'll need to explain where and why.
split_part(string text, delimiter text, field int)