簡體   English   中英

C#正則表達式解析從markdown拉出照片?

[英]C# regex parse to pull photos from markdown?

降價照片看起來像![alt text](src) 我想解析一個markdown塊,將所有照片源拉入IList<string>

我知道正則表達式可能就是答案,但它對我來說就像一個古老的神秘語言......我將如何使用C#將所有照片解析為IList<string>

示例文本

![](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**!

像這樣的東西,應該工作:

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

在這里玩,看看它是如何工作的:

http://tinyurl.com/qxjqhcs

var matches = new Regex(@"!\[.*?\]\(.*?\)")
    .Matches(str)
    .Cast<Match>()
    .Select(m => m.Value)
    .ToList();

暫無
暫無

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

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