0
我正在逐行讀取文件。在該文件中,我想用註釋行替換 #endif
聲明,其格式爲/******/
。下面的代碼不觸及該線未更換字符串
while {[gets $in line] !=-1}
{
# if substring #endif is present in the string
if { [regexp {endif} $line] } {
set line [string replace "#endif" 1 7 "/*****/" } $line]
}
}
有許多與代碼語法問題。當您嘗試運行它時是否會提供任何錯誤消息?這些通常是信息豐富的... –