我问this question earlier但我没有正确表达自己。如果我有这三种情况:如何找到不在注释中的方法名称?
void aMethod(params ...)
//void aMethod(params
// void aMethod(params
^can have any number of spaces here
我怎么能调整到符合我的正则表达式只有在字符串未在评论中发现?这是我的正则表达式:
re.search("(?<!\/\/)\s*void aMethod",buffer)
这会捕获一切:
(?<!\/\/)(?<!\s)+void onMouseReleased
这些是唯一的三种情况吗?怎么样:'/ * foo void aMethod(params)bar * /'(多行注释)和'“foo void aMethod(params)bar”'(字符串文字) –
Python没有标记器吗? – KingCrunch
@Bart,多行不会出现。 – Geo