Research and replace Word Rtf

Posted by Perello on Stack Overflow See other posts from Stack Overflow or by Perello
Published on 2012-10-12T09:34:15Z Indexed on 2012/10/12 9:36 UTC
Read the original article Hit count: 262

Filed under:
|
|
|

I'm working on an application which has a workflow for postal mails. These postal mails are generated according to my application business rules.

Models are in html or Rtf and it works perfectly as long the user do not create the rtf with word. This is not within the specs, but my hierarchy would welcome a Word compatibility if it don't involve too much work, and it would please and ease the life of our customer.

The Rtf models have tags which are replaced by application values. In most RTF, tags are not splitted, so the search and replace works perfectly. I wish to be handle word with few modifications.

Example data : [[FooBuzz]] in most rtf it's not splited.

In word 2003 :

{\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5517131 [[}{\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid2708730 FooBuzz}{\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5517131 ]]}

And their word (word 2007) splitted also Foo{garbage inside} Buzz.

So i wish to be able to handle common RTF perfectly, and detect tags even if they are splitted.

I have 2 constraints. First no regression, second it has to stay simple. Performance is not an issue here.

I'm using symfony 1.4. The actual relevant research code part :

$regExpression = '/\[\[([^\[\]]*)\]\]/';  

preg_match_all($regExpression, $sTemplate, $outKeys); 

© Stack Overflow or respective owner

Related posts about php

Related posts about word