Dear members,
I have a quick question and hope if you could kindly share your suggestions.
I'm trying to select words between parenthesis (i.e (Izmir). I've searched Geonet
for this specific task but ended up with no luck. I'm sending the screenshot
of the table. Thank you in advance.
Regards
Solved! Go to Solution.
Hi Omur,
You can accomplish this using a wildcard. For example, to do this with a feature class:
Place LIKE '%(Izmir)%'
See the section 'Search Strings' in the below link:
This forum is for help with GeoNet itself. In order to move this question to the correct forum you'll need to specify what Esri product you are using, the release of that product, and the programming language you are using.
- V
It has been moved.
Hello Vince,
Please accept my apology for posting to wrong channel.
edit: the following is to extract the word between parentheses. If you are looking to simply select features based on the word between parentheses, follow Jake's advice below.
Using Python in field calculator:
!Place!.split('(')[1].split(')')[0]
Basically, split your original string by the character '(', take the second part of that, split it by ')', and take the first part of that.
Hi Omur,
You can accomplish this using a wildcard. For example, to do this with a feature class:
Place LIKE '%(Izmir)%'
See the section 'Search Strings' in the below link:
Hello Jake,
Thank you for your suggestion. It worked . After I posted my original question I realized
that I also need to copy the words between the parenthesis to a new field. Could it be done
using Field Calculator ?
Yes, after you make the selection use the syntax Darren specified in the field calculator.
!Place!.split('(')[1].split(')')[0]
Be sure to check 'Python' at the top of the Field Calculator.
Hi Jake,
Thank you for your help. I just have one more question. How can I
copy all the words between parenthesis not only the selected records ?
You can do this by not having any features selected and using a try/except statement since not all of the rows contain values with parentheses. Ex:
It will try the code, but if the row does not contain any parentheses, it will pass this row rather than creating an error.