我的文本文件,文件的內容是這樣的:C#:解析文本文件
idiom: meaning
description.
o example1.
o example2.
idiom: meaning
description.
o example1.
o example2.
.
.
.
,你可以看到該文件包含上面的段落,每個段落有一些數據,我想提取(注該示例以o
開頭)。例如我們有這些數據:
public class Idiom
{
public string Idiom { get; set; }
public string Meaning { get; set; }
public string Description { get; set; }
public IList<IdiomExample> IdiomExamples { get; set; }
}
public class IdiomExample
{
public string Item { get; set; }
}
是否有任何方法來提取該文件中的字段?任何想法?
編輯
該文件可以是任何東西,像成語和動詞,...是例子,這只是我的示例模板:提前
little by little: gradually, slowly (also: step by step)
o Karen's health seems to be improving little by little.
o If you study regularly each day, step by step your vocabulary will increase.
to tire out: to make very weary due to difficult conditions or hard effort (also: to wear out) (S)
o The hot weather tired out the runners in the marathon.
o Does studying for final exams wear you out? It makes me feel worn out!
感謝
是的,有辦法。你有嘗試過什麼嗎? –
其實不,我對發現正則表達式的模式有點困惑。 –
含義總是單行嗎? –