Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1209.Advanced search and replace -- How to add number at end according to domain name at the begin of line?

User: basikabo -- 2014-06-28          << 1208  1210 >>
Hits: 979
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to add different number at end according to domain name at the begin of line?

1.Extract mapping of domain names and Numbers from a.txt
2.Find the document containing the domain name
3.For the line start with a domain, add the related number at the end
Input Sample:
===========================
a.txt content:
"http://www.google.it"|"8"|"--"|"--"|"--"|"--"|"--"
"http://www.yahoo.com"|"6"|"--"|"--"|"--"|"--"​|"--"

get mapping:
www.google.it => 8
www.yahoo.com => 6
===========================
Some text file:

http://www.yahoo.com|asdkfjl|
http://www.yahoo1.com|aldksfjlj|
http://www.google.it|asdkfjl|

......

Output Sample:
Add numbers at the end of line:

http://www.yahoo.com|asdkfjl|6
http://www.yahoo1.com|aldksfjlj|
http://www.google.it|asdkfjl|8

......
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open a.txt
2. ctrl-h open 'replace' dialogue
* set 'replace unit' to 'Line'
* set 'search for pattern' to

* click 'advanced' tab
* set 'run following at the beginning of replace' to:

* set 'run following for each matched unit' to:

3. click 'replace', and domainname/number mapping has been created in dictionary. Do not save file.

4. ctrl-h open 'replace' dialogue again
* set 'replace unit' to 'Line'
* set 'search for pattern' to:

* set 'replace with pattern' to:

5. click 'batch ...' button open 'batch runner' window
6. drag multiple files to 'batch runner' window
7. click 'batch replace', done.

Note: please make backup in advance to avoid mis-operation.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Screenshot 3:  Replace_Window


Similar Examples:
How to add a number in each line indicating number of words in this line? (59%)
How to insert a word or phrase to the begining of each line? (57%)
How to change the number to the corresponding letter base on mapping table? (56%)
How to add a line number at the beginning of each line? (56%)
How to move a string from the end of the line to the beginning of the line? (55%)
How to count the number of records for each month in a web log file? (54%)
How to sort the text file by the date at the beginning of each line? (54%)
How to sort the numbers in each line by the descending order in a text file? (53%)

Check Demo of Advanced search and replace
Keywords:
dictionary  diction  mapping  document  backup  doc  dic  var  create  different number  add a number to multiple file names  add beginning and end file  batch file number operation  files dictionary  batch add a number to each line  different names  operation 7  search replace mapping