1

How do I get all numbers after slash in my column? Example: 884/9 and 884/12 I need to get it as "9" and "12".

This one doesn't work - I am using Postgres and Dibi library

substring(source_path, '/(.*)$')
1
  • why doens't it work? Please provide sample results. Also what postgres version do you use? Commented May 26, 2016 at 13:10

1 Answer 1

3

If you have only one / on your data, and it is always formatted similar to the example you gave, then you can use SPLIT_PART() :

SELECT split_part(source_path, '/', 2) FROM YourTable;

Although I think your query should work. What exactly 'doesn't work' means ?

Sign up to request clarification or add additional context in comments.

2 Comments

Doesn't work means = Unknown syntax at regular '/(.*)$'. As I know, the number 2 in your code means it returns 2 chars right? I will have only one '/' but I will have N chars after it.
No, it will return all chars after it. @jax-p

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.