考慮以下字符串:如何讓正則表達式忽略括號內的所有內容?
I have been driving to {Palm.!.Beach:100} and it . was . great!!
我用下面的正則表達式來刪除所有標點符號:
$string preg_replace('/[^a-zA-Z ]+/', '', $string);
此輸出:
I have been driving to PalmBeach and it was great!!
但我需要的正則表達式來總是忽略任何介於{和}之間。因此,所需的輸出將是:
I have been driving to {Palm.!.Beach:100} and it was great
我怎樣才能讓正則表達式忽略之間是什麼{和}?
的可能的複製[小寫的一切,除了當括號(http://stackoverflow.com/questions/9229030/lowercase-everything-except-when-between-brackets) – hakre 2012-02-13 13:22:44