I want to split a text column with city names by selecting only the names like 'world (planet)' and not like 'world planet'. Tried before with left( "Name", strpos( "Name" ,' ')) update existing field and results are fine only for the names 'world (planet)' but the other names like 'world planet' disappeared from column, So tried with conditional function case when 'names'like '%(%' then left( "Name", strpos( "Name" ,'')) end (if this is a correct form of expression). Is there a way to split the names which is included the '()'? (I'm new user in QGIS.)

1 Answer 1


I used only an opening brace ( for this. Please let me know if this does not yield what you need.

left("Name" , strpos("Name" , '[(]')-2)

enter image description here

EDIT ------- to keep (5) world ( planet while cutting (1) world (planet)

WHEN regexp_substr("Name", '(^.*\\s[(]\\S)') = left("Name", strpos("Name", '[(]')+1)
THEN left("Name" , strpos("Name" , '[(]')-2)
ELSE "Name"

enter image description here

  • 1
    Yes it works perfectly. The name 'world planet' and only the name 'world' its taken from 'world (planet)' in the same column. Thank you. Dec 4, 2017 at 21:46
  • @indritleka Glad it worked out. Honestly I was uncertain about the problem you experienced. Let me upvote your question as soon as my daily limit recovers, so that it can get more proper attention.
    – Kazuhito
    Dec 4, 2017 at 22:15
  • 1
    checking the attribute table i found that some names like 'world i planet' the planet word disappear. I need another expression for those names i want to remain unchanged. So there are 'world planet' , 'world i planet' mby another like 'world i planet i world' and the last one that i want to split is 'world (planet)' . Can you help me with another expression? ibb.co/dC4iLG Dec 6, 2017 at 21:27
  • @indritleka Thanks for your feed-back. Will certainly look at it. In the meantime will you un-accept this answer so that the others also can help you?
    – Kazuhito
    Dec 6, 2017 at 23:13
  • 1
    Yes you was precise since the first expression. Both of them works perfectly. I was inattentive at the text limit field option.Thank you Dec 7, 2017 at 18:23

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.