shweta
shweta

Reputation: 117

Python regex to check if a string contains a method call

I am parsing an xml file in python. I fetch the attribute values of xml nodes for processing.

<set name="flashScope.emailSuggestion" value="userBean.createEmailSuggestion(flowRequestContext)" />

Using ElementTree, I get the attribute of the node

node.attrib['value']

which gives me

userBean.createEmailSuggestion(flowRequestContext)

Now how do I check if this string contains paranthesis ()? (I mean, to know that it is a method call)..Can anyone suggest a regex pattern for this?

Upvotes: 1

Views: 46

Answers (1)

blhsing
blhsing

Reputation: 106553

This should work in general:

^\w+(\.\w+)+\(.*\)$

Upvotes: 2

Related Questions