echo '<pre>'; print_r(1); echo '</pre>'; <- select this
echo '<pre>'; print_r($temp); echo '</pre>'; <- select this without space
// echo '<pre>'; print_r($temp); echo '</pre>'; <- skip this
echo '<pre>'; print_r($temp3); echo '</pre>'; <- select this
print_r($temp1); <- select this
// print_r($temp11); <- skip this
print_r($temp2); <- select this without spaces
if (true) {
print_r($temp4); <- select this without spaces
}
我有print語句代碼,我需要選擇唯一的非註釋語句正則表達式選擇不評論語句
這裏是一個正則表達式
^((?!\/\/\s?))(echo '<pre>';\s?)?(.+)?(print_r)(\.?)(\w+)?\((.+)?\);(echo '<\/pre>';)?
如何跳過空格? ' print_r($temp4);'
或如何更改正則表達式使其工作?
爲什麼所有的捕獲組?你想要捕捉什麼?爲什麼?這只是一個非常簡單的問題,因爲它不清楚你想要做什麼。而且,空格修剪就像在外部捕獲組中添加'\ s *'一樣簡單。 – sln
我試圖選擇「echo'
';」或者print_r($ temp2);但沒有評論 – David仍然不清楚'回聲'
';' – sln