构建正则表达式以搜索带下划线的文本 [英] build a regex to search underlined text

查看:195
本文介绍了构建正则表达式以搜索带下划线的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在实施某种技术时遇到麻烦-在带下划线的Richtextbox控件中选择下一个文本.

您会看到iam试图做一个文字处理器,但被卡住了.我已经能够按F1编写代码来逐个选择每个单词.现在,我只选择带下划线但可以是短语而不是单个单词的那些单词.

例如:hello codeproject.com-这是一个每个人都很好的网站每个人

想象我的光标在开始之前(打招呼之前),然后按F1键(或任何按钮),我想选择这是一个",然后在下一个按键上单击站点为".但是我无法为此要求构建正则表达式或实现简单的逻辑.

有什么帮助吗? (任何语言都可以-vb.net/C#)

Iam having a trouble implementing a certain technique - selecting next text in a richtextbox control which is underlined.

You see iam trying to make a word processor but am stuck. I have been able to write the code to select each word one-by-one on pressing F1. Now i want to select only those words which are underlined but can be a phrase rather than single word.

Eg: hello codeproject.com - this is a nice site for everyone

imagine my cursor is at beginning (before hello) and i press F1 (or any button) I want to select "this is a" and on next keypress "site for". But iam not being able to build a regex or implement simple logic for this requirement.

Any help plz? (Any language will do -vb.net / C#)

推荐答案

通过以下方式运行myRichTextBox.Rtf:
Run myRichTextBox.Rtf through this:
//  using System.Text.RegularExpressions;
public static Regex regex = new Regex("(?<=\\\\\\\\ul).*(?=\\\\\\\\ulnone)",
    RegexOptions.IgnoreCase
    | RegexOptions.Multiline
    | RegexOptions.CultureInvariant
    | RegexOptions.IgnorePatternWhitespace
    | RegexOptions.Compiled
    );


这篇关于构建正则表达式以搜索带下划线的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆