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