View Single Post
 
Old 01-07-2018, 12:16 AM
puff puff is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Question "Stitch" word sections together

Hi all! I have a software that generates documents with some repetitive pattern in the middle. The following is an example: "|" indicates where the repetitive starts
(normal content)...apple is red and banana | apple is red and banana is yellow...(normal content)
And I want to turn that into:
(normal content)...apple is red and banana is yellow...(normal content)

The problem is that the repetitive part's content is changeable. I can somehow control the length of the repetitive part (I can define it as integer L) and also the frequency of such thing based on time, but not word-wise or letter-wise.

My current thought is to compare a combination of several words (like "apple is red", the length of this string < L) with its possible repetitive that is located on the next Lth word; if they're the same, delete the content in between. Or search a combination within the range from itself to the next Lth word to see if there's a repetitive one and then delete the content between these 2.

Could someone help me out on this please? I also appreciate other more efficient/accurate methods. Thank you very much.
Reply With Quote