We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

searching and replacing line feeds and carriage returns

Thread ID:

Created:

Updated:

Platform:

Replies:

75790 Aug 9,2008 09:39 AM Sep 11,2008 05:44 AM Windows Forms 3
loading
Tags: DocIO
Ian Hughes
Asked On August 9, 2008 09:39 AM

I have written a search and replace routine for use with TX Text Control. It works in every instance with one exception.

When I attempt to search a line ending followed by a letter and replace it with a line ending followed by a capital letter, nothing happens.

How do I search special characters (i.e. line endings, tabs, etc.)?

Regards,
Ian

Code follows:

Public Sub SearchAndReplaceNoColor(ByVal strFileName As String, _
ByVal strSearch As String, _
ByVal strReplace As String, _
Optional ByVal boolWholword As Boolean = True, _
Optional ByVal boolCaseSensitive As Boolean = False)

'Set up minimal error handling
On Error GoTo errhandler

'Instantiate a new word document.
Dim doc As New WordDocument()

'Replace first instance
doc.ReplaceFirst = True

'The opened file has already been silently converted to a .doc file. Get the file name and open it.
If UCase(strFileName).Contains(".RTF") Then ConvertToWord(strFileName)
If UCase(strFileName).Contains(".TXT") Then ConvertToWord(strFileName)
If UCase(strFileName).Contains(".HTM") Then ConvertToWord(strFileName)
If UCase(strFileName).Contains(".HTML") Then ConvertToWord(strFileName)

strFileName = GetEverythingToTheLeftOfChar(strFileName, ".")
strFileName = strFileName & ".doc"

doc.Open(strFileName)

'Get the selection.
Dim selection As TextSelection() = doc.FindAll(strSearch, boolCaseSensitive, boolWholword)

'Iterate through each selection and replace the range.
For Each sel As TextSelection In selection
Dim range As WTextRange = sel.GetAsOneRange()
range.Text = strReplace
Next

'Save the document.
doc.Save("Sample.doc", FormatType.Doc)
'System.Diagnostics.Process.Start("Sample.doc")
frmMain.textControl1.Load("Sample.doc", TXTextControl.StreamType.MSWord)

errhandler:
Resume Next

End Sub





Bhuvaneswari P [Syncfusion]
Replied On August 11, 2008 01:48 AM

Hi Ian,

Thank you for your interest in Syncfusion products.

Currently we don't have support for find and replace the control characters. We have already logged it as a feature request and notified our development team. We will implement this feature in our forthcoming new version releases Volume4. We will get back to you once the feature is implemented.

Please let me know if you have any questions.

Best Regards,
Bhuvana




Administrator [Syncfusion]
Replied On September 10, 2008 08:17 AM

Hi Bhuvana!

I'm desperate for a search function that can select, copy, paste and replace pieces of text with control characters in them. In fact I can't do without it. I've been in contact with you before through this forum and you then suggested that I'd use bookmarks and the bookmarksnavigator to perform this task, which I've tried without achieving my goal (I'm having trouble with copying and pasting tables correctly, and the method seems shaky overall anyway). Is there some way that you could hurry the development of this function? We could be willing to pay for this.

Specifically, I would want somthing like this to work:

doc.Find(new Regex(@"\(.*)\", RegexOptions.Singleline));

This line of code should select a part in doc that could span several lines of text. Today this works for texts that reside on one single line, but fails otherwise.

I need an answer to this as quickly as possible, or we will be forced to switch to some other component.

Please contact me.

Best regards
Tobias Skillbäck
Canea AB



Bhuvaneswari P [Syncfusion]
Replied On September 11, 2008 05:44 AM

Hi Tobias,

Thank you for your interest in Syncfusion products.

We have already updated for this query in your incident post 49558, please follow up it.

Best Regards,
Bhuvana



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;