簡體   English   中英

C#正則表達式-組和嵌套組

[英]c# regex - groups and nested groups

該結構是播放列表的列表。 播放列表包括:
-靜態文本和日期;
-1-n條由索引,作者,標題組成的曲目

STATICTEXT 2011-06-18      
---------------------
01. author - title
02. author - title

STATICTEXT 2011-06-19
---------------------
01. author - title
02. author - title
03. author - title
04. author - title

我想捕獲一個播放列表。 在播放列表塊中,我想獲取其他信息,例如作者和標題。 對我來說,這是一個嵌套組的示例:每個播放列表是一個包含2個嵌套組(作者,標題)的組。

我該如何實現?

提前致謝。

R.

正則表達式在某些方面很有用,但並非對所有事情都有用。 為此文件編寫解析器非常簡單明了。

playlists = new List()
for line in file
  if line is blank
    continue
  if line starts with "STATICTEXT"
    playslists.add(playlist)
    playlist = new Playlist()
  song = parse song //this is something that regex does good
  playlist.add(song)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM