如何用正则表达是把 <UL1>ffffffffff </UL1> <http://URL-STRING/>
替换成 <a target="popup-link" href="http://URL-STRING">ffffffffff </a>
-
C# code
-
string result = Regex.Replace(urlStr, "(?i)<url>([^<]*)</url><(http://[^>]+)/>","<a target=/"popup-link/" href=/"$2/">$1</a
下面这俩个是根据我的具体情况而细化的。(日文环境下的)string result = Regex.Replace(urlStr,
"(?i)<UL1>(.*?)<UL1><(http://(.*?))>",
"<a target=/"popup-link/" href=/"$2/">$1</a>");这个是多了一个“_self'”result = Regex.Replace(result,
"(?i)<UL2>(.*?)<UL2><(http://(.*?))>",
"<a href=/"$2/" onclick=/"window.open(/'$2/','_self');/">$1</a>");
本文介绍如何使用 C# 中的正则表达式进行特定字符串的替换操作,针对日语环境下 URL 的处理进行了详细说明。通过两个具体的例子展示了如何将特定格式的文本转换为 HTML 链接。
91

被折叠的 条评论
为什么被折叠?



