3

I have a string with some spaces in it, and would like to split on the last space, and return the part of the string before that space. Does Postgres support this? I have not been able to solve this with the usual split_part-type functions.
Example : "fort worth tx" -> "fort worth"

0

2 Answers 2

3

it does not split the source string, but does what you want:

SELECT regexp_replace('fort worth tx', '\\s\\S+$', '');
Sign up to request clarification or add additional context in comments.

Comments

0

You'll need to write a plpgsql function to accomplish this. Look here for function to find last occurrence of string.

Comments

Your Answer

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.