Python regex to check if a string contains a method call

2416 views regex
-1

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?

answered question

what have you tried so far?

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

1 Answer

7

This should work in general:

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

posted this

Have an answer?

JD

Please login first before posting an answer.