此代碼將讀取文本文件中的一行: set file = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\number.txt", 1)
text = file.ReadLine
MsgBox text
我怎樣才能使它先後從同一個文件中反覆讀取一行?我想,我應該在這裏使用循環,對吧?我需要它在第一次迭代時從文件中讀取第一行
我想匹配以下內容:零長度行,匹配在非零長度的行之間繼續,直到特定的字符串在行中匹配爲止。例如:匹配以零長度線開始,並一直持續到停止: Some random text I don't care about
The match starts at the beginning of this line
The match continues across this line
The match
我試圖寫一個正則表達式來替換所有出現的\n與\r\n,除非\n已經立即被\r立即出現。我用Ruby 1.8.6這樣做不支持正則表達式向後看,所以我嘗試: # try to replace \n proceeded by anything other than \r with \r\n
str.gsub(/([^\r])\n/, "\\1\r\n") # \\1 is the captured c