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: 478
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 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 sort a text file by the length of text in each line? (59%)
How to extract the text between first comma and second comma in each line? (59%)
How to delete the first word in each line in a text file? (59%)

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