开发者

C# extracting value from string

开发者 https://www.devze.com 2023-02-07 08:59 出处:网络
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>

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

精彩评论

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