Cannot remove paragraph
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
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
SIGN IN To post a reply.
8 Replies
FS
Fathima Shalini P
Syncfusion Team
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
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
FS
Fathima Shalini P
Syncfusion Team
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.
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.
FS
Fathima Shalini P
Syncfusion Team
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
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
AD
Administrator
Syncfusion Team
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
I attached my test case here, if someone would like to look.
DocIoParagraph.zip
FS
Fathima Shalini P
Syncfusion Team
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
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
FS
Fathima Shalini P
Syncfusion Team
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
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
AD
Administrator
Syncfusion Team
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
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
BP
Bhuvaneswari P
Syncfusion Team
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
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
SIGN IN To post a reply.
- 8 Replies
- 3 Participants
-
AD Administrator
- Nov 5, 2007 05:00 AM UTC
- Jul 28, 2008 09:43 AM UTC