开发者

C# reading html attribute value using regular expression

I have a string:

str = "<img src='http://server/path/a.jpg' />blah blah blah blah";开发者_如何学Go

What would be the regular expression to find the attribute source value?

I do not want to use HTML Agility pack.

Regards,


Don't use regex to parse HTML. Use one of the many available parsers that suits your needs.

But if you really have to, for that sting this simple (and in many cases broken) regex could work for you:

\bsrc\s*=\s*["']([^"'>]+)


Use HTML agility pack; even for small things!

:: sigh ::

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜