How to select a word between parenthesis in a attribute table ?

4093
9
Jump to solution
05-07-2015 12:53 PM
FatmaŞenol
Occasional Contributor II

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

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

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:

Building a query expression—Help | ArcGIS for Desktop

View solution in original post

9 Replies
VinceAngelo
Esri Esteemed Contributor

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

KenBuja
MVP Honored Contributor

It has been moved.

FatmaŞenol
Occasional Contributor II

Hello Vince,

Please accept my apology for posting to wrong channel.

0 Kudos
DarrenWiens2
MVP Honored Contributor

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.

JakeSkinner
Esri Esteemed Contributor

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:

Building a query expression—Help | ArcGIS for Desktop

FatmaŞenol
Occasional Contributor II

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 ?

0 Kudos
JakeSkinner
Esri Esteemed Contributor

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.

FatmaŞenol
Occasional Contributor II

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 ?

0 Kudos
JakeSkinner
Esri Esteemed Contributor

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:

screen1.png

It will try the code, but if the row does not contain any parentheses, it will pass this row rather than creating an error.