选择粗体文本
我需要在 winform 应用程序中仅选择 RichTextBox 中的粗体文本,然后将其括在括号内: 例如:Rollup Action 元素描述了应应用于定义Rollup Rule
的集群活动的所需操作。
粗体文本将变为:
。谢谢。
[汇总操作] [汇总规则]
I need to select only the bold text in a RichTextBox in a winform application and then enclose it within brackets :
For example: The Rollup Action element describes the desired action that should be applied to the cluster activity that defines the Rollup Rule
.
The bold text would become:
. Thanks.
[Rollup Action] [Rollup Rule]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种解决方案是使用正则表达式查找粗体文本并将其替换为相同的内容但添加了括号:
并且 MatchEvaluator:
示例的输出将是:
您还可以更新正则表达式以确保它在所有情况下都能正常工作。
One solution would be to use Regex to find the bold text and replace it with the same thing but with brackets added:
And the MatchEvaluator:
The output for your sample would be:
You can also update the regex to be sure it works ok in all cases.