We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replace string- Special characters

Hi,

I am facing some problem while replacing string in a document using Range object.

The sample code is

Range oRange = m_oOutDoc.Range;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

int nReplace = oRange.Replace(“, “\r\r\rNovember 28, 007\r\r\rAB Road ", false, false);

The last statement actually throwing exception

“The replace string cannot contain special or break characters.”

Teh placeholder exists in a document and I'm reading the address from another document and repalcing the placeholder. The address read from the other document contains newline characters.

Thank you

Hi

Thanks for your inquiry. This question is answered in <a href="

Best regards.

\r is a paragraph break. Using such characters in the replace string is not supported in Aspose.Words.

romank:

\r is a paragraph break. Using such characters in the replace string is not supported in Aspose.Words.


Hi there.
Is there any list of such forbidden characters?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can find a list of forbidden characters in the documentation (See remarks):

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.range.replace_overload_1.html

Here you can find codes of the corresponding characters:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.controlcharfields.html

Please let me know if you need more information, I will be glad to help you.

Best regards,

alexey.noskov:

Hi

Thanks for your request. You can find a list of forbidden characters in the documentation (See remarks):

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.range.replace_overload_1.html

Here you can find codes of the corresponding characters:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.controlcharfields.html

Please let me know if you need more information, I will be glad to help you.

Best regards,


Thanks, Alexey

Alexey, one more quetion.

What the codes of: cell break, inline picture, drawing object, footnote?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry.

Cell break:

const char CellChar = (char)7; // "\a".

Inline picture and Drawing object:

const char PictureChar = (char)1;

Footnote:

const char FootnoteRefChar = (char)2;

const char FootnoteSeparatorChar = (char)3;

const char FootnoteContinuationChar = (char)4;

Best regards,

Thank you very much

Hey folks -

The links above go 404. Would you please provide an updated URL? Also, would that URL contain the valid replacement chars to use? We’re demo-ing this component, and it’s very frustrating trying to figure which char is the offender and what I can use in it’s place.

Hi
Joel,


Thanks for your inquiry. You can find the updated link below:
http://www.aspose.com/docs/display/wordsnet/Replace+Overload_1

Moreover, an exception is thrown if a captured or replacement string contain one or more special characters: paragraph break, cell break, section break, field start, field separator, field end, inline picture, drawing object, footnote.

Best Regards,

I know about the exception, I’ve been searching the forums because I’m experiencing it.

I’m looking for the links that show what are the ‘bad’ chars and what are the ‘good’ char replacements so as to avoid said exception.

Hi
Joel,


Thanks for your inquiry. Here is a list of special characters i.e. when used inside captured or replacement string, an exception is thrown:

\r
\a
\f
(char)19
(char)20
(char)21

Could you please clarify why do you need to replace these special characters? We will try to suggest some way to achieve what you are looking for.

Moreover, in future we will consider improving Replace method in order to support special characters. This thread has been linked to the appropriate issue (i.e. WORDSNET-1252) in our bug tracking system and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best Regards,

Hi,

We have encountered the same issue when updating an older system which used word automation.

An example of why this is required is when we need to optionally turn on or off certain sections in a document template - which may contain formatting such as a newline character.

a simple example from our system is:

<*IF[Invoice\GST][Yes]<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

§
In our opinion it appears there is GST.<o:p></o:p>

*> <*IF[Invoice\GST][No]<o:p></o:p>

§
In our opinion it appears there is no GST.<o:p></o:p>

*> <o:p></o:p>

Our system looks for any tags <* *> and in this case evaluates whether it should show this piece of the document (based on evaluating the fields listed) or remove it, in either case it is replacing a section which has line breaks.

We could look in to changing the tag structure and looping through the document’s content differently to try to get it to work but this could require editing around 100 template documents and a lot of additional testing.

When is a build with this issue fix is likely?

Hi Scott,

Thanks for your inquiry and sorry for the delayed response.

I have verified the status of this issue from our issue tracking system and regret to share that this issue is still unresolved. Currently it is pending for analysis and is in the queue. Also, at the moment I can't provide you the ETA for this issue. However, we will inform you via this forum thread as soon as it's resolved.

Sorry for the inconvenience.

Best Regards,

Hi Awais,

Has there been any update on this fix? This is the last item we need to address in a build and this issue is blocking us.

We need to have some indiciation of when the fix will be ready.

Hi
Scott,


Thanks for your inquiry. Unfortunately, there is no further news on this. I have asked for the ETA of this issue from our development team. As soon as, any information is shared by them, I will be more then happy to share that with you.

Best Regards,

Hi Awais,

Has there been any further update as it has been over 3 months?

We renewed our Aspose OEM licence in anticipation of being able to roll out this build sometime in the near future and now this fix is the last thing holding us up.

An ETA would be appreciated.



Hi Scott,


Thank you for your continued support of Aspose.Words. At the moment, this feature has been postponed till a later date and there is no ETA available. However, I have passed your concern to our development team. As soon as any information is shared by them, I will be glad to share that with you. We apologize for your inconvenience.

Best Regards,

Hello,


Can you have someone from your development team contact me about this? Aspose.words is marketed as a viable replacement for word automation however as discussed it’s replace function seems to be quite limited and does not provide the same flexibility as using word automation. This bug is still holding up our migration and I’m starting to wonder if this will be fixed before our maintenance is up and if not we have basically just wasted a years licence.