0

[Edit: Amended to show original mistake]

How can I simply copy everything from a column that is after a -. ?

ChatGPT gave me this (which doesn't work)

substr("name", strpos("name", '-') + 1, length("name-layer"))
1
  • you should not edit the question in a way to make the initial error by ChatGPT disappear, as like this, the problem can't be reproduced any more. So you should let your expression exactly in the way it was initially, as the only problem with the expression was that ChatGPT miraculousely inserted a non-existing fieldname name-test. When you change that to name, the question doesn't make sense any more as you already post a working solution.
    – Babel
    Commented May 28 at 8:56

1 Answer 1

6

The expression is correct, you only have to replace name-test with name:

substr("name", strpos("name", '-') + 1, length("name"))


Alternative, using Regular expressions with the function regexp_matches():

regexp_matches(name,'-(.*)')[0]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.