I have imported CAD annotation and changed it to point feature, and I have the "text string" field in table attribute. Now I want to filter any records that contain the text in parentheses. For example: the text is "100PVC (2005)" => I want to get "2005" But the field is more complicated than this example, because some records just like "(05-07)". I have tried the index function with field calculator but it did not work. I also could not select records which contain the parentheses by using the Select by Attributes. My expression was:

[TextString] LIKE '%(____)%'

When I verify that it was successfully but no records were returned.

How can I solve this problem?

2 Answers 2


Try replacing the text between the parenthesis with another % sign eg:

"NAME" LIKE '%(%)%'

This should select all rows with opening and closing parenthesis from my NAME field


For this I would recommend coming to grips with how to use the Field Calculator with the Python parser. This is described using examples in the Online Help but in the case of your specific example I would use something like this:





Code Block:

def Reclass(string):
    if string == None:
        return None
        if "(" in string:
            textInParentheses = string[string.find("(")+1:string.find(")")]
            if "-" in string:
                return "20" + textInParentheses [0:2]
                return textInParentheses
            return string

Hopefully, this will give you something to work from in order to address all your business rules. The above just looks for what's between "(" and ")" and if it has a hyphen then just grab the first two characters and put "20" in front of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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