1

markdown 中的照片看起来像![alt text](src). 我想解析一个降价块,将所有照片源拉到一个IList<string>.

我知道正则表达式可能是答案,但它对我来说就像一种古老的神秘语言......我将如何将所有照片解析成IList<string>使用 C#?

示例文本

![](http://sphotos-b.xx.fbcdn.net/hphotos-ash3/530402_10151620341829517_1993977231_n.jpg)
When I say "Japanese-Chinese" food I'm not referring to some new type of restaurant      serving both Japanese and Chinese food. This means the restaurant serves Chinese food   prepared for Japanese tastes.

![](http://sphotos-f.ak.fbcdn.net/hphotos-ak-frc1/385269_10151620364269517_1368819859_n.jpg)
This is **subuta** -- sweet and sour pork, this one photo showing the meal set (tenshoku in Japanese). It's one of many Chinese dishes this restaurant serves... and they have **A LOT**!
4

1 回答 1

3

像这样的东西,应该工作:

!\[.*?\]\(.*?\)

在这里玩一下,看看它是如何工作的:

http://tinyurl.com/qxjqhcs

var matches = new Regex(@"!\[.*?\]\(.*?\)")
    .Matches(str)
    .Cast<Match>()
    .Select(m => m.Value)
    .ToList();
于 2013-05-23T09:49:14.723 回答