---
title: "AmazReplacer - Convert Amazon's URL into your referrer URL automatically"
url: "https://osherove.com/blog/2003/9/25/amazreplacer-convert-amazons-url-into-your-referrer-url-auto.md"
canonical: "https://osherove.com/blog/2003/9/25/amazreplacer-convert-amazons-url-into-your-referrer-url-auto.html"
published: "2003-09-25T07:59:00"
updated: "2003-09-25T07:59:00"
tags: [".Net Original", "Cool sites"]
author: "Roy Osherove"
description: "I've created a small utility app that does that automatically takes whatever URL is in the clipboard , reformats it to be an Amazon referral URL and puts the result in the clipboard. Very easy and fast. You can download…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# AmazReplacer - Convert Amazon's URL into your referrer URL automatically

By Roy Osherove September 25, 2003 In [.Net Original](https://osherove.com/blog/category/net-original), [Cool sites](https://osherove.com/blog/category/cool-sites)

**Historical article** · Originally published September 25, 2003; technical details may be outdated.

I've created a small utility app that does that automatically takes whatever URL is in the clipboard , reformats it to be an [Amazon](https://osherove.com/blog/2003/9/25/www.amazon.com) referral URL and puts the result in the clipboard. Very easy and fast.

You can [download the utility(with source) here](http://royo.is-a-geek.com/files/amazreplacer.zip), but code is pretty simple to do and provides a simple example of using regular expressions and the clipboard object. Here's the gist of it:

//happens on startup

//so all is automatic. You just open the utility and BAM

//you have the good URL in your clipboard.

//Just press ESC and you're done

private void TryToAutoReplace()

{

      string current;

      try

      {

            //get the current URL from the clipboard

            //and put it in a text bo

            current = (String)Clipboard.GetDataObject().GetData(typeof(string));

      }

      catch(Exception e){return;}

      txtBefore.Text\= current;

      //replace the text in that textbox to the URL

      ReplaceAmazon();

}

private void ReplaceAmazon()

{

//find the Book ID from the URL

//could start with either 'ASIN/\[ID\]/' or 'tg/detail/-/\[ID\]/'

const string  pattern = @".\*(ASIN|tg/detail/-)/(?<book>.\\d\*)/.\*";

Match book = Regex.Match(txtBefore.Text,pattern);

if (book.Success)

{

      //add you referrer ID to the end of the 'good' URL

      // thanks to [Hugh Brown](http://www.iwebthereforeiam.com/) for showing the short version of the url 

txtAfter.Text =@"http://www.amazon.com/o/ASIN/" +

book.Groups\["book"\].Value + @"/iserializable-20";

      //make the result available via "paste"

      Clipboard.SetDataObject(txtAfter.Text ,true);

      }

}

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Sep 30, 2003

    ### [Unit Test Your .NET Data Access Layer: Where are the Mocks?](https://osherove.com/blog/2003/9/30/unit-test-your-net-data-access-layer-where-are-the-mocks.html)

- Sep 28, 2003

    ### [\[New article\]: Creating a generic Site-To-RSS tool (site scraping)](https://osherove.com/blog/2003/9/28/new-article-creating-a-generic-site-to-rss-tool-site-scrapin.html)

- Sep 24, 2003

    ### [\[Article\] Fun with Unit Tests – Testing abstract classes](https://osherove.com/blog/2003/9/24/article-fun-with-unit-tests-testing-abstract-classes.html)

- Sep 23, 2003

    ### [I'm available](https://osherove.com/blog/2003/9/23/im-available.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
