简体   繁体   English

Python正则表达式检查字符串是否包含方法调用

[英]Python regex to check if a string contains a method call

I am parsing an xml file in python. 我正在用python解析xml文件。 I fetch the attribute values of xml nodes for processing. 我获取xml节点的属性值进行处理。

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

Using ElementTree, I get the attribute of the node 使用ElementTree,我获得了节点的属性

node.attrib['value']

which gives me 这给了我

userBean.createEmailSuggestion(flowRequestContext)

Now how do I check if this string contains paranthesis () ? 现在如何检查此字符串是否包含paranthesis () (I mean, to know that it is a method call)..Can anyone suggest a regex pattern for this? (我的意思是,要知道这是一个方法调用)。有人可以为此建议一个正则表达式模式吗?

一般而言,这应该起作用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM