Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1040.Advanced search and replace -- How to join first half of One line with last half of another?

User: Aaron -- 2012-12-24          << 1039  1041 >>
Hits: 3093
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
Splice First Half of One line Together With First Half of Another.
Input Sample:
1. Count the number of words in first line of source text.  
 
Source: The boy ran all the way home because it started to rain hard. (13 words) 
 
(More lines follow with different word counts for each etc.)  
 
2. Replace first 50% of words from number 1 above (6-7 words in this example) with first 50% of words from another line from target text file, resulting in mixed lines. 
   
Target: The little girl cried loudly when the dog barked. (10 words total, 50% = 5 words) 
 
(More lines follow ..
Output Sample:
3. Output:  The little girl cried loudly because it started to rain hard. 
 
Could also be: The little girl cried loudly home because it started to rain hard. 
 
(More mixed lines follow that are a combination of the source and target lines etc.) 
                 
4. Repeat this process for each sentence in source and target files.  
 
Correct grammar or punctuation not required.
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Assume 2 files are: d:\test\1.txt and 2.txt 
1. ctrl-o open 1.txt 
2. ctrl-h open 'replace' dialogue: 
* set 'replace unit' to 'Line' 
* set 'replace with pattern' to: 
 
3. click 'replace', done. 
4. ctrl-s save to file.

Screenshot 1:  Replace_Window


Similar Examples:
How to add first line to the start of each line? (57%)
How to fill in one xml file with elements from another xml file? (56%)
How to extract half of lines from a text file randomly? (55%)
How to sort all the lines of a text file randomly? (55%)
How to join all odd lines together and all even lines together? (54%)
How to remove the first 10 characters of each line in text file? (54%)
How to extract all lines that has more than 2 numbers? (52%)
How to delete the first word in each line in a text file? (52%)

Check Demo of Advanced search and replace
Keywords:
together  test  last  count  ass  las  how to join  join  sum  spli  replace another  replace first last  another file  join files  last line  line last  join 2 line  join line