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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cannot remove paragraph

Thread ID:

Created:

Updated:

Platform:

Replies:

69604 Nov 5,2007 05:00 AM UTC Jul 28,2008 09:43 AM UTC WinForms 8
loading
Tags: DocIO
Administrator [Syncfusion]
Asked On November 5, 2007 05:00 AM UTC

Hi,

I am having trouble in removing text which include paragraphs with the Replace function in DocIO.

Example: (this works on a System.String)
string text = "Hello.[start]\r\n Line to remove.[end] Hello.";
string search = "\\[start\\](.*)\\[end\\]";
Regex expr = new Regex(search,RegexOptions.Singleline);
string t1 = expr.Replace(text, "");
===
t1 will be "Hello. Hello."

However if I try the same with a Word document I cannot figure out how to make a Regular expression which will remove the paragraph separator (\r\n in text).

Can anybody help?

Is this possible in some other manner?

Thanks
Jens

Fathima Shalini P [Syncfusion]
Replied On November 6, 2007 04:05 AM UTC

Hi Jens,

Thank you for your interest in Syncfusion Products.

To replace the \n character in RegularExpression you can add one more escape character like the following code snippet.

string text = "Hello.[start]\r\\n Line to remove.[end] Hello.";
string search = "\\[start\\](.*)\\[end\\]";
paragraph.AppendText(text);
Regex expr = new Regex(search);
int t1 = document.Replace(expr,"");

For more details, please have a look at following link.

http://websamples.syncfusion.com/samples/DocIO.Windows/ReplacingSample/main.htm

I will update you with full details by tomorrow.

Regards,
Fathima Shalini.P

>Hi,

I am having trouble in removing text which include paragraphs with the Replace function in DocIO.

Example: (this works on a System.String)
string text = "Hello.[start]\r\n Line to remove.[end] Hello.";
string search = "\\[start\\](.*)\\[end\\]";
Regex expr = new Regex(search,RegexOptions.Singleline);
string t1 = expr.Replace(text, "");
===
t1 will be "Hello. Hello."

However if I try the same with a Word document I cannot figure out how to make a Regular expression which will remove the paragraph separator (\r\n in text).

Can anybody help?

Is this possible in some other manner?

Thanks
Jens


Fathima Shalini P [Syncfusion]
Replied On November 6, 2007 04:10 AM UTC

Hi Jens,

Thank you for your interest in Syncfusion Products.

To replace the \n character in RegularExpression you can add one more escape character like the following code snippet.

string text = "Hello.[start]\r\\n Line to remove.[end] Hello.";
string search = "\\[start\\](.*)\\[end\\]";
paragraph.AppendText(text);
Regex expr = new Regex(search);
int t1 = document.Replace(expr,"");

For more details, please have a look at following link.

http://websamples.syncfusion.com/samples/DocIO.Windows/ReplacingSample/main.htm

I will update you with full details by tomorrow.


Fathima Shalini P [Syncfusion]
Replied On November 6, 2007 06:21 AM UTC

Hi Jens,

As this is suspected to be a defect, can you please create a Direct-Trac Incident with TITLE: [Forum id(69604) - '\n' escape character is not replaced using RegEx ]. This will be more helpful for us to investigate further in this issue.

Regards,
Fathima Shalini.P

Administrator [Syncfusion]
Replied On November 7, 2007 06:32 AM UTC

The Direct Track report is: 38888
I attached my test case here, if someone would like to look.


DocIoParagraph.zip

Fathima Shalini P [Syncfusion]
Replied On December 18, 2007 02:21 PM UTC

Hi Jens,

On further analysis, we have found that " '\n' escape character is not replaced by RegEx " is not an issue. With our code library it is not possible to replace the text which involves line breaks or escape sequences.

Please let me know if you have any other concerns.

Regards,
Fathima


Fathima Shalini P [Syncfusion]
Replied On December 20, 2007 11:48 AM UTC

Hi Jens,

Support for '\n' character in find and replace

I regret to let you know that currently we do not provide support for this feature in our code library. We have notified our development team on this regard and will get back to you once we hear back from them.

Regards,
Fathima


Administrator [Syncfusion]
Replied On July 23, 2008 11:57 AM UTC

What's the status on this issue? I bought this component with the assumption that regex would work as normal, i.e. with support for newline in search/replace. I can't do without this function and will have to switch to one of your competitors if this is not fixed (soon!).

Regards
Tobias

>Hi Jens,

Support for '\n' character in find and replace

I regret to let you know that currently we do not provide support for this feature in our code library. We have notified our development team on this regard and will get back to you once we hear back from them.

Regards,
Fathima




Bhuvaneswari P [Syncfusion]
Replied On July 28, 2008 09:43 AM UTC

Hi Tobias,

Sorry for the delay in getting back to you.

I am able to see the issue. This is due to DocIO perform replace for every paragraph. In the given document we have two paragraphs. First paragraph contains "Address1 [start]", second - "Address2 [end]". So if we perform replace for each paragraph, the paragraph (separately) doesn't contain "\\[start\\](.*)\\[end\\]" string. So we recommended you to perform replace separately for "\\[start\\]" and "\\[end\\". But replacing the content between the start and end, unfortunately such operation ( for given document ) can't be performed using replace method. As a workaround you can insert bookmarks which marks start and end of the text, and use BookmarkNavigator to replace text.

Here is the sample for your reference:
http://websamples.syncfusion.com/samples/DocIO.Windows/F69604_1/main.htm

Please let me know if you requires any other details.

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.

Warning Icon 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.Close Icon

;