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.)
Add a comment
|
1 Answer
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)
EDIT ------- to keep (5) world ( planet
while cutting (1) world (planet)
CASE
WHEN regexp_substr("Name", '(^.*\\s[(]\\S)') = left("Name", strpos("Name", '[(]')+1)
THEN left("Name" , strpos("Name" , '[(]')-2)
ELSE "Name"
END
-
1Yes it works perfectly. The name 'world planet' and only the name 'world' its taken from 'world (planet)' in the same column. Thank you. Commented 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.– KazuhitoCommented Dec 4, 2017 at 22:15
-
1checking 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 Commented 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?– KazuhitoCommented Dec 6, 2017 at 23:13
-
1Yes you was precise since the first expression. Both of them works perfectly. I was inattentive at the text limit field option.Thank you Commented Dec 7, 2017 at 18:23