Using Regular Expressions with a RichTextBox

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

Anyone know how to use Regular Expressions to search in a RichTextBox?


Thanks in advance
 
| Anyone know how to use Regular Expressions to search in a RichTextBox?


yes.

hth,

steve
 
maybe i could be more verbose if you would afford the same
luxury...say...maybe what you're trying to do?!!!


| anyone else??
|
| | > | Anyone know how to use Regular Expressions to search in a RichTextBox?
| >
| >
| > yes.
| >
| > hth,
| >
| > steve
| >
| >
|
|
 
All I want to do is to search a RichTextBox's text using a Regular
Expression.

I've tried it using the tom interface but can't make it work.

Below is a little of the code.

I've tried another NG and concluded no one knew how.
This NG is great, I've gotten fantastic answers to almost every question
I've asked, except those that relate to the RichTextBox. So I assume no one
here is doing hardcore stuff with it, but I thought I'd try.


What does hth mean?


Thanks for asking for more input.


Dim IDocument As tom.ITextDocument =
GetCtlEdit(Me).TextControl1.GetOLEInterface()

-snip

If chkWholeWords.Checked Then lFlags = RichEdit.Flags.MatchWord

If chkMatchCase.Checked Then lFlags = lFlags Or RichEdit.Flags.MatchCase

If chkRegularExpressions.Checked Then lFlags = lFlags Or
RichEdit.Flags.MatchPattern

Select Case aFindType

Case gFIND_FROM_THE_END

lSearchRange = GetCtlEdit(Me).TxtRangeAll

lintFoundPos = FindText(lSearchRange,
cboFindStr.Text, -lSearchRange.StoryLength, lFlags)

Case gFIND_FROM_THE_START

--snip

Private Function FindText(ByRef aRange As tom.ITextRange, ByVal aFindString
As String, ByVal aCount As Integer, ByVal aFlags As Integer) As Integer

If aCount = 0 Then

FindText = 0

Else

If aCount < 0 Then

FindText = aRange.FindTextEnd(aFindString, aCount, aFlags)

If FindText > 0 Then aRange.Start = aRange.End - FindText

Else

FindText = aRange.FindTextStart(aFindString, aCount, aFlags)

If FindText > 0 Then aRange.End = aRange.Start + FindText

End If

End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top