使用正则表达式添加关闭/使用<img>

Cha*_*ark 0 html regex tags

<img src="images/btn_studyroom.gif" border="0">
Run Code Online (Sandbox Code Playgroud)

我是asp程序员.我需要更改所有网站以便访问网页.

我想改变<img>标签

<img~~~><img~~~/>

如何/>使用正则表达式添加?

Cas*_*yte 5

首先,>之前的斜杠不是"更容易访问"但xhtml严格兼容.我不是asp专家,但你可以尝试这样的事情:

String newText = Regex.Replace(inputString, @"(<img[^>]+)(?<!/)(?=>)", "\1/");
Run Code Online (Sandbox Code Playgroud)