我有以下txt文件:
31.03.15 15:46:42 Broker=Varengold Bank AG Server=VarengoldBank-Demo AccNo=1234673584 Curr=EUR IsDemo=TRUE Digits=5 Pair=EURUSD Balance=0 |
31.03.15 15:46:42 MT0 Datacenter: |
31.03.15 15:46:42 ;MT[0] Bid 1,07394|
Logfile rotation initiated.|
我使用StreamReader.ReadLine()
来读取数据。
如何使用Regex匹配这样的数据:
Ex: 31.03.15 15:46:42 MT0 Datacenter: |
Datetime = 31.03.15 15:46:42
Content=MT0 Datacenter: (remove "|")
with second line:
Datetime=31.03.15 15:46:42
Content=MT[0] Bid 1,07394 (remove ";|")
最后一个是: 日期时间= Content =启动日志文件轮换。
答案 0 :(得分:0)
(?:\d\d[\.]){2}\d\d (?:\d\d[:]){2}\d\d
将与Datetime匹配。对于内容,您可以这样:
[A-Za-z].+(?=[|])
这将使您的行以字母字符开头,以|。
结尾