简单的正则表达式 - 替换 C# 中论坛主题中的引用信息
我认为这应该是非常简单的。
我有这个字符串:
[quote=Joe Johnson|1]Hi![/quote]
应该用类似的东西替换,
<div class="quote">Hi!<div><a href="users/details/1">JoeJohnson</a></div></div>
我很确定这进展不太顺利。到目前为止,我有这个:
Regex regexQuote = new Regex(@"\[quote\=(.*?)\|(.*?)\](.*?)\[\/quote\]");
有人能指出我正确的方向吗?
任何帮助表示赞赏!
This should be pretty straightforward I would think.
I have this string:
[quote=Joe Johnson|1]Hi![/quote]
Which should be replaced with something like
<div class="quote">Hi!<div><a href="users/details/1">JoeJohnson</a></div></div>
I'm pretty shure this is not going very well. So far I have this:
Regex regexQuote = new Regex(@"\[quote\=(.*?)\|(.*?)\](.*?)\[\/quote\]");
Can anyone point me in the right direction?
Any help appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
Try this:
你为什么不说你也想处理嵌套标签...
我几乎没有使用过正则表达式,但事情是这样的:
why didn't you said you want to deal with nested tags as well...
i've barely ever worked with regex, but here the thing:
这应该是点网中的正则表达式:
\[quote\=(?(.*))\|(?(.*))\](?( .*))\[\/引用\]
this should be your regex in dot net:
\[quote\=(?<name>(.*))\|(?<id>(.*))\](?<content>(.*))\[\/quote\]