Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1144.Text file splitter -- How to batch split file delimitered by first dash in each line?

User: Aaron -- 2013-10-28          << 1143  1145 >>
Hits: 1474
Type: Text file splitter   
Search all Text file splitter examples
I would like to extract and save text that follows the first dash in a line to one file and save the word or phrase before the dash to another file.

Please note that there may be other dashes after the first but I would like to save all the text following the first dash only. Each line may or may not end with punctuation.
Input Sample:
Input Example:

Word1 - asdfadfasfa - jkh;h;jhljhlh

Phrase 2 - oiuyiyoiuyoiuyouy

Word3 - qwerqerqerqerq - uipipiupiupi?

Output Sample:
Output File 1: Words or phrases before the first dash.

Phrase 2

Output File 2: Text that follows the first dash.

asdfadfasfa - jkh;h;jhljhlh
qwerqerqerqerq - uipipiupiupi?
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Assume you want to extract 1st part to file.1.txt, 2nd part to file.2.txt

1. open "Tools->Batch Runner" window
2. drag all text files to "Batch Runner" window
3. change the "set filename" entry to:

4. click "Fast Replace" button to open "Fast replace" dialogue
5. click "add" to add replace rule
* leave "search" to be 
* set "replace" to be blank
* click "ok"
6. make sure "regular expression" option is checked, and UNcheck "cross line" option
7. click "start", all text before "-" will be write to file.1.txt

To write the content after "-" to new files, you just need:
* change step 3 to:
* change step 5 "search" to: 

Screenshot 1:  Batch_Runner_Window

Screenshot 2:  Fast_Replace_Window

Similar Examples:
How to batch split file delimitered by second comma in each line? (85%)
How to batch replace files with specified format in each line? (70%)
How to split a text file according to first word in each line? (68%)
How to split a text file to different files according to first word in each line? (65%)
How to sort file by the number which first appear in each line? (65%)
How to split a text file to different files according to first word in each line? (65%)
How to batch insert filename at start/beginning of each lines? (62%)
How to process text files, only keep the first word of each line? (61%)

Check Demo of Text file splitter
batch split file delimiter  dash  punctuation  split file delimiter  unctuation  leave  1st  phrase  2nd  batch split  text file splitter regular expression  split by regular expression text file splitter  text file splitter blank line  extract 1st line  a word in text and replace with another with batch  add text to phrase  split text file by phrase  change filename after and before dash