问问题
171 次
2 回答
1
根据 HamZa DzCyberDeV 的评论,我在RegexHero中使用了 RegEx 模式,发现 RegExHero 甚至生成了 ASP.NET。因此,下面的简单代码完全达到了我需要的结果:
Dim s As String = txt_input.Text.Trim
Dim strRegex As String = "\[url\s?=\s?""?(.*?)""?\](.*?)\[\/url\]"
Dim myRegex As New Regex(strRegex)
Dim strReplace As String = "<a href=""$1"">$2</a>"
ltl_output.Text = myRegex.Replace(s, strReplace)
于 2013-05-13T13:43:55.033 回答
0
据我了解,您需要一个用于 ASP.NET 的 BBCode 转换器,您可以在此处找到。
给定链接的示例:
string BBCodeSyntax = "[url={webaddress}]{display}[/url]";
string HtmlSyntax = "<a href=\"{webaddress}\">{display}</a>";
string Fields = "{webaddress};{display}";
string input = "For those who code - [url=http://www.codeproject.com]The CodeProject[/url]. This website contains lots of articles about programming. For open source project hosting from Microsoft, you may have a look at [url=http://www.codeplex.com]Codeplex.com[/url].";
string output = BBCode.ConvertToHtml(input, BBCodeSyntax, HtmlSyntax, Fields);
return output;
于 2013-05-13T08:52:02.333 回答