0

I have a table os which contains below data

id         name
--         ----
1          windows server 2012 R2
2          windows 2016 SQL
3          Oracle linux 7.5

I need to extract 2012 R2 from windows server 2012 R2 and 2016 SQL from windows 2016 SQL and 7.5 from Oracle linux 7.5

I tried below query but it returns only the number like 2012 and 2016 and 7

SELECT name, substring(name FROM '[0-9]+') FROM os;

For eg How can I extract 2012 R2 from windows server 2012 R2 using postgresql query?

2
  • 2
    What if it has strings like 7.5.1 or 2012 Release 2 etc? Commented Nov 22, 2018 at 8:01
  • I need to extract 7.5.1 and 2012 Release 2 as well Commented Nov 22, 2018 at 8:16

1 Answer 1

3

Please try SELECT name, substring(name FROM '[0-9]+.*') FROM os;

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

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.