User: Aaron -- 2013-12-10 << 1156 1158 >> |
Hits: 3246 |
Type: Text file parser |
Search all Text file parser examples |
Description: |
Thank you for script 1156. In a similar method what is the best way to randomly delete lines that don't contain text in brackets based on the same percentage calculation as script 1156? |
Input Sample: |
Line 1 aaaa bbb ccc ddd eee (some text in brackets) Line 2 aaaa bbbbbb c dd eee Line 3 aaaa bbb cc dd ee fff Line 4 (more text in brackets) Line 5 aaa bbb ccc d eee f ggg Line 6 aa (even more text) Line 7 a b ccc d e ff gg Line 8 aaaaa bbb ccc dd e ff gg (and more too) etc Randomly delete 50% of lines NOT containing (text in brackets) |
Output Sample: |
Possible output: Line 1 aaaa bbb ccc ddd eee (some text in brackets) Line 2 aaaa bbbbbb c dd eee Line 4 (more text in brackets) Line 5 aaa bbb ccc d eee f ggg Line 6 aa (even more text) Line 8 aaaaa bbb ccc dd e ff gg (and more too) or ... Line 1 aaaa bbb ccc ddd eee (some text in brackets) Line 3 aaaa bbb cc dd ee fff Line 4 (more text in brackets) Line 6 aa (even more text) Line 7 a b ccc d e ff gg Line 8 aaaaa bbb ccc dd e ff gg (and more too) etc. |
Answer: |
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps. |
1. ctrl-o open 'text' file 2. ctrl-h open 'replace' dialogue * set 'replace with pattern' to: * click 'advanced' tab set 'run following for each matched unit' to: 3. click 'replace', done. Note: you can adjust 0.5 to other values. |
Screenshot 1: Replace_Window |
Screenshot 2: Replace_Advanced_Window |