Replace Pioneer Home
All Examples
Free Download
all
Advanced search and replace
Replace text in multiple files
Regular expression replace
Batch file rename
Batch download
Text file parser
Text file splitter
Html text generator
Search replace binary
Random word generator
Count and statistics
Character encoding
Bin Hex Oct Dec converter
Text generator
Text sort
Text merge
Text data calculation
RSS: Replace Pioneer Examples
543.Advanced search and replace -- How to delete all lines whose first word appeared in previous line?
User:
editor -- 2010-06-22
<< 542
544 >>
Hits:
3364
Type:
Advanced search and replace
Search all
Advanced search and replace
examples
Description:
How to delete all lines whose first word appeared in previous line?
In the example below, make the line started with AAA,BBB,CCC only appeared once.
Input Sample:
AAA line1
BBB line2
AAA line3
CCC line4
BBB line5
Output Sample:
AAA line1
BBB line2
CCC line4
Answer:
Hint: You need to
Download and install "Replace Pioneer"
on windows platform to finish following steps.
1. ctrl-o open source text file
2. ctrl-h open replace window
* set 'replace unit' to 'Line'
* in 'replace with pattern', enter:
$A
click 'advanced' page:
* in 'run following at the beginning of replace' enter:
clear_values_all()
* in 'run following for each matched unit' enter:
if (get_value($match[1])==1 ) { $A=""; } else {$A="$match\n"; set_value($match[1],1); }
3. click 'replace', done!
4. ctrl-s save to file.
Similar Examples:
How to delete/remove all lines that appearred more than once?
(64%)
How to delete rows with same column as previous line?
(62%)
How to replace all lines before first blank line?
(62%)
How to delete from FILE A all lines that appear in file B?
(62%)
How to delete all lines containing specific word in specific column?
(61%)
How to delete all lines appear in file B from file A?
(61%)
How to delete all lines that contain only a word and a blank?
(59%)
How to delete all columns with more than 8 words in text file?
(59%)
Check Demo of
Advanced search and replace
Keywords:
line started with
previous
aaa
delete all lines
else
first word
values
delete all
clear
at the beginning
delete first word of each line
delete first word in each line
delete lines with word
delete first word
delete beginning line
delete first lines
delete text at beginning
delete first line in text