我問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