Python regex to check if a string contains a method call

2416 views regex

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


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?

answered question

what have you tried so far?

if "(" in string and ")" in string: ... ? .. maybe check also that ( before ) ...

1 Answer


This should work in general:


posted this

Have an answer?


Please login first before posting an answer.