Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

514.Advanced search and replace -- How to enclose all the odd number of lines with a pair of tags?

User: editor -- 2010-05-19          << 513  515 >>
Hits: 367
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to enclose all the odd number of lines with a pair of tags?
I have a file containing some data, I want to add a pair of <name> </name> at the begin and end of every odd line, and leave the even line untouched, how can I achieve it?
Input Sample:
Tommy
23
Jenny
56
Mark
18
...
Output Sample:
<name>Tommy</name>
23
<name>Jenny</name>
56
<name>Mark</name>
18
...
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open source text file
2. ctrl-h open replace dialog
* set "Replace Unit" to "Line"
* set "Unit Number filter" to:

Note: 1<2> means only handle line of 1,3,5,7,...(start=1, step=2, end=infinite)
* set "Replace with pattern" to:

3. click "Replace", done!
Download Script:  scripts/514.rst.zip

Similar Examples:
How to expand all the numbers in the list and seperate them by comma? (58%)
How to sort all the numbers in each line randomly? (56%)
How to reverse all the words in each line of a csv file? (56%)
How to replace all duplicate lines with some text? (55%)
How to reset all the numbers with format id=NNN in a text file?  (55%)
How to convert all numbers from decimal to percentage? (54%)
How to remove all the lines that with odd line number for multiple files? (54%)
How to replace all the numbers in a text file to the square value? (54%)

Check Demo of Advanced search and replace
Keywords:
leave  odd line  odd  even  tags  tag  number of lines  unit number filter  number filter  containing  odd even  enclose all lines  search and replace odd lines  lines tags  add lines every lines  add line every lines  add text every line  add text to end of line