Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1089.Text file parser -- How to extract text between brackets into a file and the rest in another?

User: Aaron -- 2013-06-22          << 1088  1090 >>
Hits: 3362
Type: Text file parser   
Search all Text file parser examples
Description:
I would like to extract and save text between brackets to a one file. Also, save the text outside the brackets to another file as per the output examples.
Input Sample:
Billy's mother checked her watch. (It's time for us to go.) 
(I don't want to go to the doctor.) Billy cried and ran into his room.  
His mother knocked on his door. (Billy, you come out here right now.)  
Billy hid under his bed. (No, I'm never coming out.)
Output Sample:
Output: 
 
Extract all text between ( and ) brackets in following format: 
 
(It's time for us to go.) 
(I don't want to go to the doctor.)  
(Billy, you come out here right now.)  
(No, I'm never coming out.) 
etc. 
 
Extract all text outside brackets: 
 
Billy's mother checked her watch. 
Billy cried and ran into his room.  
His mother knocked on his door.  
Billy hid under his bed. 
etc.
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. open "Tools->Batch Runner" window 
2. drag all(or one) 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 blank 
* set "replace" to:  
* click "ok" 
6. make sure regular expression option is checked, click "start", all text with bracket will be write to new files with name of file.bracket.ext 
 
To write the content without bracket to new files, you just need: 
* change step 3 to: 
* change step 5 to:  

Screenshot 1:  Batch_Runner_Window


Screenshot 2:  Fast_Replace_Window


Similar Examples:
How to extract text between specified start and end strings? (67%)
How to extract content between 2-1000 lines from multiple txt files? (58%)
How to extract from a file according to content of another file? (57%)
How to extract the text between first comma and second comma in each line? (57%)
How to replace everything outside brackets with lines from another file? (56%)
How to get content between a pair of nearest ab bc? (55%)
How to move text before first square bracket to the replace of the parenthesis? (55%)
How to extract tables from html files into csv file automatically? (55%)

Check Demo of Text file parser
Keywords:
brackets  bracket  extract text between  leave  another file  write  without  blank  between  example  regular expression replace examples  extract bracket  filename without  examples of text  replace all examples  output filename replace examples  extract between  extract content