1
我試圖編寫一些正則表達式,在比賽前返回1個字符。例如正則表達式 - 比賽前返回1個字符
:record1: Has text here with "\n" as the end of line \n
however, there can be multiple line \n
and I dont know how many before I get to the next record \n
:record2: has some other date in it \n
我現在的正則表達式,試圖找到RECORD1長相結束這樣
(\n)(?=:record2:)
我還想捕獲上次\ n,但這樣我就可以得到它的位置。關於如何在字符串匹配之前立即捕獲字符的任何想法?
'*(\ n):RECORD2:'會捕獲上次'\ N'字符串之前。但是,「位置」是什麼意思,以及您使用的是什麼工具/語言? –
你爲什麼不用'\ n:record:'來分割你的字符串?(並刪除數字)? – antoni
我使用專有工具將文本文件轉換爲xml。該工具允許您使用正則表達式定義開始和結束標籤。我想定義一個結束標記,以便在\ n之前標識\ n:record2: – TheUltimateHack