Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

128.Advanced search and replace -- How to process text files, only keep the first word of each line?

User: editor -- 2008-05-18          << 127  129 >>
Hits: 2118
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to process text files, only keep the first word of each line? 
Input Sample:
abide abode,abided abode,abided  
arise arose arisen  
awake awoke awaked,awoken  
be was been  
bear bore borne,born  
beat beat beaten  
become became become  
... 
Output Sample:
abide 
arise 
awake 
be 
bear 
beat 
become 
...
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. press ctrl-o open source file 
2. press ctrl-h open 'Replace' dialog 
in 'Replace' page, 
* set 'Replace unit' to 'Line' 
* set 'Search for pattern': 
 
* set 'Replace with pattern': 
 
3. click 'Replace', done. 
 
Note: $match[1] means the first word of matched line 
Download Script:  scripts/128.rst.zip

Screenshot 1:  Replace_Window


Similar Examples:
How to split a text file according to first word in each line? (75%)
How to remove the text from line start to the first ":" in each line? (67%)
How to split a text file to different files according to first word in each line? (66%)
How to split a text file to different files according to first word in each line? (66%)
How to batch split file delimitered by first dash in each line? (62%)
How to sort file by the number which first appear in each line? (60%)
How to batch rename files with the first word of file contents? (60%)
How to extract and join first words from adjacent lines? (59%)

Check Demo of Advanced search and replace
Keywords:
process  keep  first word  the first  means  first  mean  rst  matched  replace page  keep only first word  keep first  only first  pattern first word  only search text  replace text first line  first files  search and replace first