如何在两个标签之间获取字符串

时间:2012-04-04 09:16:39

标签: c# regex strip

我想知道如何在两个已知标签之间获取字符串(或字符串数​​组)。 例如,我有这个字符串

string var1="my first video is [video]http://video.com/aaa[/video] and my second is[video id=\"1\" length=\"3\"]http://video.com/bbb[/video]";

如何获取这些值http://video.com/aaahttp://video.com/bbb

1 个答案:

答案 0 :(得分:3)

使用此模式:@"\[video.*?\](.*?)\[/video\]"然后获取组1.我不会发布整个代码,因为我不想为你做你的工作。阅读C#Regexes,Patterns并尝试用这种模式编写代码。

相关问题