0
我在一個txt文件中有一個php腳本。我想如何爲HTML創建語法高亮。這意味着,我必須替換所有字符串,並在前面添加span標籤,並在結尾添加結束標籤。PHP/Regex:如何替換PHP腳本中的所有字符串
如果txt文件我讀這個樣子的
<?php
function test() {
echo "this is output" . getB() . 'another string';
}
function getB() {
retrurn "b";
}
test();
?>
它應該是這樣的我正則表達式後:
<?php
function test() {
echo <span style='color: red;'>"this is output"</span> . getB() . <span style='color: red;'>'another string'</span>;
}
function getB() {
retrurn <span style='color: red;'>"b"</span>;
}
test();
?>
我怎樣才能解決這個使用正則表達式?謝謝你的幫助!
那麼「text \」或者類似的東西呢? – FailedDev