Research and replace Word Rtf
- by Perello
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);