开发者

C# extracting value from string

I'm trying to extract a value from a string. The string looks like this:

<iframe src="/test.php?aed=asd" width="0" height="0" scrolling="no" frameborder="0"></iframe>

The only thing that changes in the link is the value after aed. What would be the easiest way to extract it?

Than开发者_Go百科ks


To do this properly you should be using an HTML parsing library, but for a simple extraction, you can use something like:

Regex.Match(s, @"(?<=/test\.php\?aed=)[^""&]+").Value

Means: after seeing the string "/test.php?aed=", match everything up to the next quote or ampersand.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜